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

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

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

#思路:因为要保留8月没有练题的人,所以不能把表连接以后用日期去筛选,而是要先筛选后做表连接;
#①选出复旦的人,形成tb1;
#②选出8月做题的人,形成tb2;
#③tb1左联tb2,分组计算即可。

select tb1.device_id, university, 
count(question_id), 
count(if(result='wrong',null,result))
from 
(select device_id, university from user_profile where university='复旦大学') tb1 
left join 
(select device_id, question_id, result from question_practice_detail
where date_format(date,'%Y%m')='202108') tb2
on tb1.device_id=tb2.device_id 
group by tb1.device_id, university

全部评论

相关推荐

10-20 11:11
辽宁大学 营销
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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