0

I have a table like:

 id  Description       date
 01  used by st1      2018-11-10 10:10:11
 02  used by st6      2018-10-10 09:10:11
 01  used by st1      2017-10-10 09:10:11
 01  used by st3      2017-10-08 09:10:11
 ..

I need to select the rows with the latest inserted ids ignoring any other occurrence of a row with the same id. Is there a way to do this?

Jose Cabrera Zuniga
  • 2,348
  • 3
  • 31
  • 56
  • Possible duplicate of [Using LIMIT within GROUP BY to get N results per group?](https://stackoverflow.com/questions/2129693/using-limit-within-group-by-to-get-n-results-per-group) – melwil Jul 30 '18 at 14:00
  • 1
    `SELECT DISTINCT ON (id) * FROM table ORDER BY date DESC` – 404 Jul 30 '18 at 14:39

0 Answers0