首页 > 技术文章 > oracle-over(partition by..)

seeall 2020-10-13 09:23 原文

时间: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排序,结果集只获取每个组的第一条数据;

推荐阅读