select concat('layer', c.rk) as layer, count(c.rk) as count from (select b.mall_id, case  when b.t2/b.t1 >= 0 and b.t2/b.t1 <= 0.1 then '1' when b.t2/b.t1 > 0.1 and b.t2/b.t1 <= 0.2 then '2' when b.t2/b.t1 > 0.2 and b.t2/b.t1 <= 0.3 then '3' when b.t2/b.t1 > 0.3 and b.t2/b.t1 <= 0.4 then '4' when b.t2/b.t1 > 0.4 and b.t2/b.t1 <= 0.5 then '5' when b.t2/b.t1 > 0.5 and b.t2/b.t1 <= 0.6 then '6' when b.t2/b.t1 > 0.6 and b.t2/b.t1 <= 0.7 then '7' when b.t2/b.t1 > 0.7 and b.t2/b.t1 <= 0.8 then '8' when b.t2/b.t1 > 0.8 and b.t2/b.t1 <= 0.9 then '9' else '10' end as rk from (select a.mall_id, sum(a.total_gmv) as t1, sum(a.total_gmv) over(order by a.total_gmv desc) as t2 from (select mall_id, sum(gmv) as total_gmv from mall_gmv group by mall_id) a) b) c group by c.rk order by layer; 同2楼的思路,内部排序还是gmv降序,感觉题目表述不清,和小红书那个差不多
点赞 16

相关推荐

04-13 20:24
Java
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务