查询产品销售总额排行前3和最后3名的产品ID

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

posted @ 2012-10-12 19:50  顿金  阅读(219)  评论(0编辑  收藏  举报