MSSQL 分组后取每组第一条(group by order by)

MSSQL 分组后取每组第一条(group by order by)

 

select * from ( select ROW_NUMBER() over(partition by x order by y desc) RowNum ,testTable.* from testTable) as t1 where RowNum = 1

记录一下,以后会用到

posted @ 2017-08-29 11:14  发型真帅  阅读(292)  评论(0编辑  收藏