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

sql server seleziona la prima riga da un gruppo

select a,b
from (
select a,b,row_number() over(partition by a order by b desc) as roworder
from myTable
) temp
where roworder = 1

vedere http://msdn.microsoft.com/en-us/library/ms186734.aspx