题解 | #所有用户对高难度题目的刷题数#

所有用户对高难度题目的刷题数

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

select 
t1.device_id,
convert(sum(if(difficult_level='hard',1,0)),signed) as question_cnt
from
user_profile t1
left join 
question_practice_detail t2
on t1.device_id =t2.device_id 
left join question_detail t3
on t2.question_id =t3.question_id 
# where t3.difficult_level ='hard'
group by t1.device_id
order by question_cnt asc

这题的难点在于,需要统计没有做过的用户,所以不能将difficult_level放在where过滤条件里面,需要在统计的时候进行判断。

全部评论

相关推荐

迟缓的马里奥求你们别...:我双2,FPGA方向,在成都找工作投了上百家,收到面试的不超过10家,是成都这个地方太有说法了。西南柬埔寨
秋招,不懂就问
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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