0
    ID   Date
    13  2021-03-24 00:00:00.000
    13  2021-03-23 00:00:00.000
    13  2014-12-27 00:00:00.000
    52  2021-03-17 00:00:00.000
    52  2020-06-21 00:00:00.000
    120 2021-04-21 00:00:00.000
    141 2021-05-04 00:00:00.000


select distinct ID, [Date]
from Table
group by  Id, [Date]
order by Id, [Date] desc

But my intention is to get something like this, only the TOP value for each ID, having the [Date] descending:

 ID     Date
 13     2021-03-24 00:00:00.000
 52     2021-03-17 00:00:00.000
 120    2021-04-21 00:00:00.000
 141    2021-05-04 00:00:00.000
Akhtubir
  • 131
  • 1
  • 6
  • 1
    Does this answer your question? [Select first row in each GROUP BY group?](https://stackoverflow.com/questions/3800551/select-first-row-in-each-group-by-group) – AGB Jul 13 '21 at 10:48

0 Answers0