Sqlserver
 sql >> Database >  >> RDS >> Sqlserver

Trova l'ultima riga nel gruppo per query-SQL Server

select ID, Name 
FROM (select ID, Name, -- add other columns here
             ROW_NUMBER() over (partition by Name ORDER BY ID DESC) as MAX_ID
      from Customer) x
WHERE MAX_ID = 1