当前位置:Gxlcms >
数据库问题 >
MSSQL 分组后取每组第一条(group by order by)
MSSQL 分组后取每组第一条(group by order by)
时间:2021-07-01 10:21:17
帮助过:53人阅读
* from (
select ROW_NUMBER()
over(partition
by x
order by y
desc) RowNum ,testTable.
* from testTable)
as t1
where RowNum
= 1
记录一下,以后会用到
MSSQL 分组后取每组第一条(group by order by)
标签:number group row order order by font sql mssql log