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

连续签到领金币

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

select uid,month,sum(c) coin
from(
select uid,month,(case when count(sign)=7 then 15 when count(sign)>=3 then count(sign)+2 else count(sign) end) c
from(
select uid,date_format(in_time,'%Y%m') month,date_sub(date(in_time),
    interval (case when row_number()over(partition by uid order by in_time)%7=0 then 7 else row_number()over(partition by uid order by in_time)%7 end) day) sign
from tb_user_log
where sign_in=1 and date(in_time) between '2021-7-7' and '2021-10-31' and artical_id=0
)a
group by uid,month,sign
    )b
group by month,uid
order by month,uid
全部评论

相关推荐

11-03 18:50
门头沟学院 Java
迷茫的大四🐶:问就是马上到,一周五天,6个月以上,全国可飞
点赞 评论 收藏
分享
Java转测开第一人:这种就是饼 把应届当廉价劳动力用完然后丢掉
你觉得今年秋招难吗
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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