题解 | #统计活跃间隔对用户分级结果#

连续签到领金币

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

#对签到进行一个排序,连续签到的排序和时间的差值是一样的
#窗口函数不能用别名??
SELECT uid,date_format(dt,'%Y%m') as mon,sum(
case when lxqd in (0,1,3,4,5) then 1
    when lxqd = 2 then 3
    when lxqd = 6 then 7
    end
)
from
(
SELECT * ,(rank() over (partition by uid,date_cha order by dt)-1)%7 as lxqd
FROM
(
SELECT *,date_sub(dt,interval rk day) as date_cha 
FROM(
SELECT uid ,date(in_time) as dt,rank() over(partition by uid order by date(in_time)) as rk
from tb_user_log
where artical_id = 0 and sign_in = 1
and date(in_time)>='2021-07-07' and date(in_time)<= '2021-10-31'
)l
)ll

)lll
group by uid,mon


全部评论
(partition by uid,date_cha order by dt)-1)请问这段为啥要-1呢
点赞 回复 分享
发布于 2022-02-21 01:25

相关推荐

11-26 22:34
已编辑
重庆邮电大学 Java
快手 客户端开发 (n+5)k*16 公积金12
牛客895077908号:佬 什么双非硕啊
点赞 评论 收藏
分享
11-03 14:38
重庆大学 Java
AAA求offer教程:我手都抬起来了又揣裤兜了
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务