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

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

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

四个条件:

1.高难度SQL试卷平均分大于80

2.7级红名dalao

3.统计2021年 试卷完成数和题目练习数

4.只保留2021年有试卷完成记录的用户


select t.uid,
count(distinct exam_id) as exam_cnt,
count(distinct question_id,t1.submit_time) as question_cnt
from exam_record t
left join 
(select *
from
practice_record
where year(submit_time)=2021) t1   
on t.uid = t1.uid

where t.uid in (select uid from user_info where level = 7)
  and year(t.submit_time)=2021
  and year(t.submit_time) is not NULL
  and t.uid in 
              (select uid
               from exam_record t
               join examination_info t1 on t.exam_id = t1.exam_id
               where year(t.submit_time)=2021
                 and year(t.submit_time) is not NULL
                 and tag='SQL' 
                 and difficulty='hard'
               group by uid
               having AVG(score)>80
              )

group by t.uid
order by exam_cnt asc,question_cnt desc
全部评论

相关推荐

07-03 16:02
门头沟学院 Java
点赞 评论 收藏
分享
门口唉提是地铁杀:之前b站被一个游戏demo深深的吸引了。看up主页发现是个初创公司,而且还在招人,也是一天60。二面的时候要我做一个登录验证和传输文件两个微服务,做完要我推到github仓库,还要我加上jaeger和一堆运维工具做性能测试并且面试的时候投屏演示。我傻乎乎的做完以后人家跟我说一句现在暂时不招人,1分钱没拿到全是白干
你的秋招第一场笔试是哪家
点赞 评论 收藏
分享
评论
3
收藏
分享

创作者周榜

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