题解 | #统计复旦用户8月练题情况#
统计复旦用户8月练题情况
https://www.nowcoder.com/practice/53235096538a456b9220fce120c062b3
#解法一 select b.device_id,university, count(question_id) as question_cnt, count(case when result='right' then 1 else null end) as right_question_cnt from (select device_id,university from user_profile where university = "复旦大学") as a left join ( select device_id,question_id,result from question_practice_detail where month(date)="08")as b on a.device_id=b.device_id group by b.device_id; #解法二 select b.device_id,university, sum(if(question_id is null,0,1)) question_cnt, sum(if(result="wrong",0,1)) right_question_cnt from ( select device_id,university from user_profile where university="复旦大学") a left join ( select device_id,question_id,result from question_practice_detail where month(date)='08') b on a.device_id=b.device_id group by b.device_id;