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

连续签到领金币

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

with t as (
    select uid,date(in_time) as dint,
           date(in_time)-dense_rank()over(partition by uid order by in_time) as start_time
    from tb_user_log
    where artical_id=0 and sign_in=1 and date(in_time) between '2021-07-07' and '2021-10-31'
)
select uid,date_format(dint,"%Y%m") as month,sum(case rn%7 when 3 then 3 when 0 then 7 else 1 end) as coin
FROM
    (
      select *,
      dense_rank()over(partition by uid,start_time order by dint) as rn
      from t
    ) t1
group by uid,month
order by month,uid
全部评论

相关推荐

不愿透露姓名的神秘牛友
07-01 11:27
点赞 评论 收藏
分享
06-14 19:09
门头沟学院 Java
darius_:给制造业搞的,什么物料管理生产管理,设备管理点检,最最关键的就是一堆报表看板。个人觉得没啥技术含量都是些基本的crud,但是业务很繁琐那种
点赞 评论 收藏
分享
评论
6
收藏
分享

创作者周榜

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