题解 | #统计复旦用户8月练题情况#

统计复旦用户8月练题情况

https://www.nowcoder.com/practice/53235096538a456b9220fce120c062b3

select up.device_id,up.university,count(q.device_id) question_cnt,sum(if(result = 'right',1,0)) right_question_cnt
from user_profile up
left join question_practice_detail q
on up.device_id=q.device_id 
where up.university='复旦大学' and (date like '2021-08-%' or date is null)
group by up.device_id;
这个题目有难度,如果直接用date是8月份去筛选的话,没有答题的同学会被忽略,下面这种解法也很好:
select up.device_id,up.university,count(q.device_id) question_cnt,sum(if(result = 'right',1,0)) right_question_cnt
from user_profile up
left join question_practice_detail q
on up.device_id=q.device_id and date like '2021-08-%'
where up.university='复旦大学'  
group by up.device_id;

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-15 17:46
暑期就挂了,秋招还有机会吗
大聪明777:研发提前批,14号刚开的,官网上面的配图上有写。提前批没过的话,秋招还可以投,不过前面的笔试/面试记录会被保留,供秋招参考
26届校招投递进展
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
05-25 18:29
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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