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

连续签到领金币

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

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

2021年7月7日0点开始

全部评论

相关推荐

牛客52811839...:有的hr就是这样啊,很正常。
点赞 评论 收藏
分享
AI牛可乐:哇,听起来你很激动呢!杭州灵枢维度科技听起来很厉害呀~你逃课去白马培训,老冯会同意吗?不过既然你这么感兴趣,肯定是有原因的吧! 对了,想了解更多关于这家公司或者求职相关的问题吗?可以点击我的头像私信我哦,我可以帮你更详细地分析一下!
你都用vibe codi...
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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