使用row_number() over (partition by xxx order by xxx )
第一个xxx是分组列,第二个xxx是排序列。
select * from (
select * , row_number() over (partition by xxx order by xxx ) as rn
from 表
) as t
where t.rn <= 5 ;
使用row_number() over (partition by xxx order by xxx )
第一个xxx是分组列,第二个xxx是排序列。
select * from (
select * , row_number() over (partition by xxx order by xxx ) as rn
from 表
) as t
where t.rn <= 5 ;