SQLSERVER 查询分组后获取每组的最新一条数据

代码如下

 1 select  from (
 2     select 
 3         row_number() over(partition by x order by y desc) as rid
 4         ,
 5     from z
 6 ) as tt
 7 where tt.rid=1
13 --按x分组,以y排序

 

posted @ 2020-06-11 11:52  小小的菜鸟程序员  阅读(2883)  评论(0编辑  收藏  举报