列表

详情


44. 选取订单量前1000的商品,并且选出每个商品订单量排名前100的销售渠道

回答思路

订单表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

上一题