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

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

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

select a.uid, count(distinct  year(a.time),month(a.time)) 'act_month_total',
count(distinct case when year(a.time)='2021' then date(a.time) else null end) 'act_days_2021',
count(distinct case when (year(a.time) = '2021' and a.type = 'exam') then date(a.time) else null end) 'act_days_2021_exam',
count(distinct case when (year(a.time) = '2021' and a.type = 'question') then date(a.time) else null end) 'act_days_2021_question'
from (select i.uid,exam_id,r.start_time 'time','exam' as 'type'
from user_info i left join exam_record r on i.uid = r.uid
union all
select i.uid, r.question_id,r.submit_time 'time','question' as 'type'
from user_info i left join practice_record r on i.uid = r.uid
) a
where a.uid in
(select uid
from user_info
where level = '7' or level = '6')
group by a.uid
order by act_month_total desc,act_days_2021 desc

全部评论

相关推荐

今年读完研的我无房无车无对象,月入还没有过万 看到他在朋友圈晒房产证,感叹自己白读了这么多年书
梦想是成为七海千秋:那咋了,双9毕业的现在还没存款呢(因为没念完),高中毕业的去直播带货月入几百万也是完全有可能的,退一万步讲,有些人刚出生父母就给买车买房了,上哪说理去,哪怕是同一个起点也会有截然不同的走向,过好自己的生活就完事了。
点赞 评论 收藏
分享
05-23 20:31
已编辑
武汉大学 Java
内向的柠檬精在研究求职打法:注意把武大标粗标大 本地你俩不是乱杀
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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