select pid from
(select pid,ROW_NUMBER() over (order by sum(amount) ) s1,ROW_NUMBER() over (order by sum(amount) desc) s2 from pro
group by pid)t
where s1<=3 or s2<=3
查询产品销售总额排行前3和最后3名的产品ID
最新推荐文章于 2022-06-20 03:31:22 发布
select pid from
(select pid,ROW_NUMBER() over (order by sum(amount) ) s1,ROW_NUMBER() over (order by sum(amount) desc) s2 from pro
group by pid)t
where s1<=3 or s2<=3