题解 | #连续签到领金币#

连续签到领金币

https://www.nowcoder.com/practice/aef5adcef574468c82659e8911bb297f

select uid,concat('2021',m) as "month", sum(coin_m) as "coin"
from (
select uid,count(1),m,case when count(1) >=7 then (floor(count(1)/7)*15 + (case when (count(1)%7)>=3 then count(1)%7+2 else count(1)%7 end))
                           when count(1) >=3 then count(1)+2 else count(1) end "coin_m"
from(

select uid,in_time,m,(day(in_time) - ranking) as "const_d",sign_in
from(

select uid,in_time,lpad(month(in_time),2,0) as "m",row_number()over(partition by uid order by in_time) as "ranking",sign_in
from tb_user_log
where in_time between '2021-07-07 00:00:00' and '2021-10-31 23:59:59' 
and artical_id = 0 and sign_in = 1
)t1   
)t2
group by uid,const_d,m    
)t3     
group by uid,m          
order by month,uid

全部评论

相关推荐

风中翠竹:真的真的真的没有kpi。。。面试官是没有任何kpi的,捞是真的想试试看这个行不行,碰碰运气,或者是面试官比较闲现在,没事捞个人看看。kpi算HR那边,但是只有你入职了,kpi才作数,面试是没有的。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务