题解 | 每个6/7级用户活跃情况

每个6/7级用户活跃情况

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

with base_data as (
    select
        uid,
        date(start_time) as active_dt,
        1 as isexam
    from exam_record
    union all
    select
        uid,
        date(submit_time) as active_dt,
        1 as isexam
    from exam_record 
    union all 
    select
        uid,
        date(submit_time) as active_dt,
        0 as isexam
    from practice_record
)

select
    u.uid,
    count(distinct date_format(b.active_dt,'%Y-%m')) as act_month_total,
    count(distinct if(year(b.active_dt)=2021,b.active_dt,null)) as act_days_2021,
    count(distinct if(year(b.active_dt)=2021 and b.isexam=1,b.active_dt,null)) as act_days_2021_exam,
    count(distinct if(year(b.active_dt)=2021 and b.isexam=0,b.active_dt,null)) as act_days_2021_question
from user_info u
left join base_data b on u.uid = b.uid
where u.level in (6,7)
group by u.uid
order by act_month_total desc, act_days_2021 desc;

全部评论

相关推荐

debug 到凌晨 ...:还有这种雷霆提问,我都不懂这种提问何意味啊?“你为什么不用 Coze 直接拖一下?”“我:因为 Coze 适合标准化场景,业务复杂的时候要自己写……”;他:“那你写的不就是工作流吗?哪里 Agent 了?”;真给我干沉默了。。。 小公司做Agent真就挺草台的
想做Agent可以做哪些...
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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