select * from (
select *,row_number() over (partition by 分组字段 order by 排序字段 desc nulls last)maxx from 表名
)as temp
where temp.maxx< 2
上面是取分组排序后最大的一条,反之就是取最小的。
select * from (
select *,row_number() over (partition by 分组字段 order by 排序字段 desc nulls last)maxx from 表名
)as temp
where temp.maxx< 2
上面是取分组排序后最大的一条,反之就是取最小的。