Sqlserver
 sql >> Datenbank >  >> RDS >> Sqlserver

Suchen Sie die letzte Zeile in der Gruppe nach Abfrage-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