A和W的区别 | #满足条件的用户的试卷完成数和题目练习数#

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

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

select a.uid uid, count(distinct e.score) exam_cnt, count(distinct p.score) question_cnt
from
(select u.uid uid, avg(score) avg
from user_info u
left join exam_record r
on u.uid = r.uid
left join examination_info i
on r.exam_id = i.exam_id
where tag = 'SQL' and difficulty = 'hard' and level = 7
group by uid) a
left join exam_record e
on a.uid = e.uid and year(e.submit_time) = 2021
left join practice_record p
on a.uid = p.uid and year(p.submit_time) = 2021
where avg > 80
group by uid order by exam_cnt, question_cnt desc;

and和where的区别,and不对结果进行筛选,会返回null值,where对结果进行筛选。

全部评论

相关推荐

牛客928043833号:在他心里你已经是他的员工了
点赞 评论 收藏
分享
群星之怒:不是哥们,你就不好奇瘫痪三十年的老植物人是啥样的吗?
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务