MSSQL 分组后取每组第一条(group by order by)
--根据 x 分组后、根据 y 排序后取第一条 select * from ( select ROW_NUMBER() over(partition by x order by y desc) RowNum ,testTable.* from testTable) as t1 where RowNum = 1
MySQL分组取每组前一(或几)条记录(排名)
--根据 x 分组后、根据 y 排序后取第一条 select * from ( select ROW_NUMBER() over(partition by x order by y desc) RowNum ,testTable.* from testTable) as t1 where RowNum = 1
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。