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

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

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

select uid,
count(distinct uid,date_format(tm,"%Y%m")) as act_month_total,
count(distinct case when year(tm)= 2021 then uid + date_format(tm,"%Y%m%d") else NULL end) as act_days_2021,
count(distinct case when (year(tm)= 2021 and left(exam_id,1)=9) then uid + date_format(tm,"%Y%m%d") else NULL end ) as act_days_2021_exam,
count(distinct case when (year(tm)= 2021 and left(exam_id,1)=8) then uid + date_format(tm,"%Y%m%d") else NULL end ) as act_days_2021_question
from
(select uid,exam_id,start_time as tm from exam_record
union
select uid,question_id,submit_time as tm from practice_record) ep
right join user_info using(uid)
where level in (6,7)
group by uid
order by act_month_total desc,act_days_2021 desc

全部评论

相关推荐

牛客85811352...:1希音不知道算不算大厂 2完全符合,过得很舒服, 3确实只有杂活 领导找我续签到明年3、4月我要继续吗。主要是边实习边秋招这段时间还是有点累
什么是优秀的实习经历
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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