oracle-over(partition by..)

时间:2020年10月13日

sql语句:

select * from

(

select t.*, row_number() over(partition by t.字段1,t.字段2 order by t.字段3 desc) no

from 表 t

where 条件

) temp

where temp.no = 1

 

含义:

根据字段1 + 字段2分组,每个分组根据字段3排序,结果集只获取每个组的第一条数据;

posted @ 2020-10-13 09:23  seeAll  阅读(119)  评论(0编辑  收藏  举报