题解 | #满足条件的用户的试卷完成数和题目练习数#

满足条件的用户的试卷完成数和题目练习数

https://www.nowcoder.com/practice/5c03f761b36046649ee71f05e1ceecbf

select uid,
COUNT(if(test='exam_id',1,NULL)) as exam_cnt ,#统计考试类别的试卷数
COUNT(if(test='question_id',1,NULL)) as question_cnt#统计练习类别的试卷数
from(
select uid,'exam_id' as test
from exam_record
where year(submit_time)='2021' and score is not null 
union all
select uid,'question_id' as test
from practice_record
where year(submit_time)='2021' and score is not null 
)k -- 筛选符合条件的试卷
where uid in -- 筛选大佬
(
select ui.uid
from user_info as ui
inner join exam_record as er on ui.uid = er.uid
inner join examination_info ei on ei.exam_id=er.exam_id
where ui.level=7 and ei.tag='SQL' and
      ei.difficulty='hard' and year(submit_time)='2021'
group by ui.uid
having avg(score)>80
) 
group by uid
order by exam_cnt asc,question_cnt desc

全部评论

相关推荐

不知道怎么取名字_:两个方向 1.简历针对性准备下 2.面试前也需要准备的 主要还是要看各个公司需求,看公司行业和岗位描述,那里面已经写了对技术的需求,一份简历,不可能和所有嵌入式岗位都匹配的
投递北京经纬恒润科技股份有限公司等公司6个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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