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

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

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

with 
user_info as 
    (select uid from user_info  where level in (6,7)),
examination_info as 
    (select exam_id from examination_info),
union_table as
    (select uid,start_time as time,exam_id as eq  from exam_record
    union all 
    select uid,submit_time as time,question_id as eq from practice_record)

select
    t1.uid,
    count(distinct date_format(t2.time,'%Y%m')) as act_month_total,
    count(distinct case when year(t2.time) = 2021 then date_format(t2.time,'%m%d') else null end ) as act_days_2021,
    count(distinct case when (year(t2.time) = 2021 and t2.eq in (select exam_id from examination_info)) then date_format(t2.time,'%m%d') else null end) as act_days_2021_exam,
    count(distinct case when (year(t2.time) = 2021 and t2.eq not in (select exam_id from examination_info)) then date_format(t2.time,'%m%d') else null end) as act_days_2021_question
from
    user_info t1
left join
    union_table t2
on 
    t1.uid = t2.uid
group by
    t1.uid
order by
    act_month_total desc,act_days_2021 desc

全部评论

相关推荐

能干的三文鱼刷了10...:公司可能有弄嵌入式需要会画pcb的需求,而且pcb能快速直观看出一个人某方面的实力。看看是否有面试资格。问你问题也能ai出来,pcb这东西能作假概率不高
点赞 评论 收藏
分享
屌丝逆袭咸鱼计划:心态摆好,man,晚点找早点找到最后都是为了提升自己好进正职,努力提升自己才是最关键的😤难道说现在找不到找的太晚了就炸了可以鸡鸡了吗😤早实习晚实习不都是为了以后多积累,大四学长有的秋招进的也不妨碍有的春招进,人生就这样
点赞 评论 收藏
分享
xdm怎么说 要被拷打了 担心是KPI
丹田:面就完了,就当日薪四位数的大佬免费给给你面试。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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