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

连续签到领金币

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

with t1 as (select uid,date(in_time) dt
from tb_user_log 
where artical_id = 0
and in_time < '2021-11-01'
and in_time >= '2021-07-07'
and sign_in = 1
group by uid,date(in_time)
),
t2 as (select uid,dt,rank() over (partition by uid order by dt ASC) rank_num
from t1
),
t3 as (select uid,dt,rank_num,date_add(dt,interval - rank_num day) rank_dt
from t2)

select uid,replace(substr(dt,1,7),'-','') month,
sum(case when coin_num % 7 = 3 then 3 when coin_num % 7 = 0 then 7 else 1 end) coin
from (select uid,dt,rank() over (partition by uid,rank_dt order by dt) coin_num
from t3) u 
group by uid,replace(substr(dt,1,7),'-','')
order by month,uid ASC

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-01 12:22
点赞 评论 收藏
分享
机械打工仔:我来告诉你原因,是因为sobb有在线简历,有些HR为了快会直接先看在线简历,初步感觉不合适就不会找你要详细的了
投了多少份简历才上岸
点赞 评论 收藏
分享
06-23 11:43
门头沟学院 Java
allin校招的烤冷...:我靠,今天中午我也是这个hr隔一个星期发消息给我。问的问题还是一模一样的😅
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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