select * from (
select *,row_number() over (partition by 分组字段 order by 排序字段 desc nulls last)maxx from 表名
)as temp
where temp.maxx< 2
desc:查询最大
asc:查询最小
select * from (
select *,row_number() over (partition by 分组字段 order by 排序字段 desc nulls last)maxx from 表名
)as temp
where temp.maxx< 2
desc:查询最大
asc:查询最小