题解 | #SQL类别高难度试卷得分的截断平均值#

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

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

select
uid
,exam_cnt
,if(question_cnt is null,0,question_cnt)
from
(select
uid
,count(submit_time) exam_cnt
FROM exam_record
where year(submit_time)=2021
group by uid) a
left join
(select
uid
,count(submit_time) question_cnt
FROM  practice_record
where year(submit_time)=2021
group by uid) b
using (uid)
where uid in
(select
uid
from user_info
join exam_record
using (uid)
join examination_info
using (exam_id)
where tag='SQL'
and level=7
and difficulty='hard'
group by uid
having avg(score)>=80)
order by exam_cnt,question_cnt desc
非常考验整合的一题,需要慢慢吃透。记住count(null)=0
全部评论

相关推荐

06-07 21:26
江南大学 C++
话不多说,直接上时间线和图片1.2024年10月底发offer,并签三方2.2025年5月底公司违约
从零开始的转码生活:希望所有签了三方但直接违约的公司都倒闭!都倒闭!都倒闭!
点赞 评论 收藏
分享
自由水:笑死了,敢这么面试不敢让别人说
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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