回答思路
订单表a:sid:商品id;channel:销售渠道;amount:订单量。 select sid, channel from (select sid, sum(amount) as amt from a group by sid) t1join (select sid, channel, row_number() over (partition by sid order by amount desc) as rk from a) t2 on t1.sid = t2.sid where rk <= 100 order by amt desc limit 1000