题解 | #每个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

全部评论

相关推荐

06-27 18:53
门头沟学院 Java
这样才知道自己不适合搞代码,考公去咯
只爱喝白开水:我也发现不适合搞代码,打算转非技术方向了
点赞 评论 收藏
分享
06-19 19:06
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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