select u.device_id,u.university,count(q.question_id) as question_cnt, sum(if(q.result="right",1,0)) as right_question_cnt from user_profile as u left join question_practice_detail as q on u.device_id=q.device_id and month(q.date)=8 where u.university="复旦大学" group by u.device_id