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

连续签到领金币

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

select
uid,
date_format(dt,"%Y%m") `month`,
 sum(get_coin_num) coin
from(select
     uid,
     dt,
     date_sub(dt,interval rk-1 day) start_date,
    case(dense_rank() over(partition by uid,date_sub(dt,interval rk-1 day) order by dt))%7 when 3 then 3
     when 0 then 7
     else 1 end get_coin_num
from(select
uid,
date(in_time) dt,
dense_rank() over(partition by uid order by date(in_time)) rk
from tb_user_log
where artical_id=0 and sign_in=1 
    and date(in_time) between '2021-07-07' and '2021-10-31')t)t
group by uid,date_format(dt,"%Y%m")
order by `month`,uid

全部评论

相关推荐

11-17 14:18
门头沟学院 C++
代码飞升_不回私信人...:这种感觉还好。只是你写一个PPT,可能他面的快一点而已。那种让你写什么方案,写什么代码的那种。就没必要去了。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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