Kamin_H level
获赞
2
粉丝
0
关注
0
看过 TA
1
清华大学
2018
数据分析师
IP属地:广东
暂未填写个人简介
私信
关注
2020-03-23 17:47
已编辑
清华大学 数据分析师
舞哈哈哈:使用MySQL做的,个人理解 select t1.order_add_user, t1.num, count(distinct t2.num)+1 as rank, (case when count(distinct t2.num)+1<=3 then t1.num*50+1000 else t1.num*50 end) as bonus from (select order_add_user, sum(quantity) as num, date_format(order_add_time,"%Y-%m") as month from order where order_add_time<=date_format(now(),"%YYYY-%mm-%dd") and order_add_time>date_format(now(),"%Y-%m-01") group by order_add_user order by num desc limit 10 ) t1 left join (select order_add_user, sum(quantity) as num, date_format(order_add_time,"%Y-%m") as month from order where order_add_time<=date_format(now(),"%YYYY-%mm-%dd") and order_add_time>date_format(now(),"%Y-%m-01") group by order_add_user order by num desc limit 10 ) t2 on t1.num<t2.num group by t1.order_add_user order by t1.num desc;
0 点赞 评论 收藏
分享
关注他的用户也关注了:
牛客网
牛客企业服务