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

连续签到领金币

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

select uid,month,sum((case when nums%7>=3 then 2 else 0 end)+floor(nums/7)*8+nums)as coin
from 
(select uid,date_format(d,'%Y%m')as month,count(ct)as nums
from 
(select d,uid,num,(d-num)as ct
from 
(select distinct date(in_time)as d,uid,
row_number()over(partition by uid order by in_time)as num
from tb_user_log
where artical_id=0 and date(in_time)between '2021-07-07' and '2021-10-31' and sign_in=1)t1)t2
group by uid,month,ct)t3
group by uid,month
order by month,uid
全部评论

相关推荐

11-18 09:44
Java
小白也想要offer:简历别放洋屁,搞不还还放错了,当然你投外企除外,以上纯属个人观点
点赞 评论 收藏
分享
评论
1
收藏
分享
牛客网
牛客企业服务