SELECT up.university, df.difficult_level, ROUND(COUNT(*) / COUNT(DISTINCT dq.device_id),4) "avg_answer_id" FROM user_profile up LEFT JOIN question_practice_detail dq ON up.device_id = dq.device_id LEFT JOIN question_detail df ON dq.question_id = df.question_id WHERE dq.question_id IS NOT NULL GROUP BY up.university, df.difficult_level
从上一题学会了一个神奇的写法
COUNT(DISTINCT dq.device_id)