需要判断月份
通过IF语句可以设置值
用SUM统计所有值
SELECT up.device_id,up.university,SUM(IF(MONTH(date)=8,1,0)) AS question_cnt,SUM(IF(MONTH(date)=8 AND result='right',1,0)) AS right_question_cnt
FROM user_profile up
LEFT JOIN question_practice_detail qpd
ON up.device_id = qpd.device_id
WHERE university = '复旦大学'
GROUP BY up.device_id