题解 | 连续签到领金币

连续签到领金币

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

#每天金币数
select uid,date_format(d,'%Y%m') as month,sum(day_coin) as coin
from
(select uid,d,
(case when count(primary_date) over(partition by uid,primary_date  order by d) %7 =3 then 3
when count(primary_date) over(partition by uid,primary_date  order by d) %7 =0 then 7
else 1 end) as day_coin
from(select uid,date_format(in_time,'%Y%m%d') as d,date_sub(date_format(in_time,'%Y%m%d'),interval row_number() over(partition by uid order by in_time) day) as primary_date
from tb_user_log
where date_format(in_time,'%Y%m%d') between '20210707' and '20211031'
and artical_id =0
and sign_in =1)a)b
group by uid,date_format(d,'%Y%m')

三刷 count(primary_date) over(partition by uid,primary_date order by d) 标红容易遗忘

全部评论

相关推荐

02-07 10:52
复旦大学 Java
混子不想混:非常能理解,感觉他们就靠着入行早,打压新人一样。我这个公司也是,天天干的累死累活,然后绩效打C,合着让新人被绩效,像是年底攒棺材本一样。总是打击之后,还会让人开始自我怀疑,是不是我努力的还不够,实际上并不是,就是他们不做人,故意打压新人。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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