题解 | #统计复旦用户8月练题情况#
统计复旦用户8月练题情况
https://www.nowcoder.com/practice/53235096538a456b9220fce120c062b3
select up1.device_id,university,count(question_id) question_cnt, sum(if(result='right',1,0)) as right_question_cnt from (select device_id,university from user_profile where university='复旦大学') as up1 left join question_practice_detail as qd on up1.device_id=qd.device_id and month(date)='8' group by up1.device_id;计算逻辑感觉复杂了。看看有没有跟简单的。用了多重嵌套。