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

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

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

select uid,
count(distinct date_format(start_time,'%Y%m')) as act_month_total,
count(distinct if(year(start_time)=2021,date_format(start_time,'%Y%m%d'),null)) as act_days_2021,
这个一直不会表示 借鉴了评论区才想到了给下面两个加标签 
count(distinct if(year(start_time)=2021 and tag='exam',date_format(start_time,'%Y%m%d'),null)) as act_days_2021_exam,
count(distinct if(year(start_time)=2021 and tag='practice',date_format(start_time,'%Y%m%d'),null)) as act_days_2021_question
from
(
    select uid,start_time,'exam' as tag
    from exam_record
    union
    select uid,submit_time,'practice' as tag
    from practice_record
) as t1
right join user_info using(uid)
这里用过where uid in ()和left join 结果1003那个都是不出现 后来知道要以ui表为依托 才会出现4个0 
where level=6 or level=7
group by uid
order by act_month_total desc,act_days_2021 desc
随笔记录之 今天竟然在学校图书馆见到了一个小学生 真服了  为什么要放没有一卡通的人进来 




全部评论

相关推荐

酷酷我灵儿帅:这去不去和线不线下面说实话没啥关系
点赞 评论 收藏
分享
都是平常模拟联系了,开个摄像头,还要不要隐私了。。。
SalaryWish...:可能想还原真实面试场景吧,而且一些企业的AI面都是牛客做的,我觉得底层是一样的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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