select d.university, d.difficult_level, sum(d.queNums) / count(d.device_id) as avg_answer_cnt from ( select a.university, a.device_id, c.difficult_level, count(c.difficult_level) as queNums from user_profile ...