select university,count(question_practice_detail.question_id) / count(distinct question_practice_detail.device_id) as avg_answer_cnt
from question_practice_detail
join user_profile
on question_practice_detail.device_id=user_profile.device_id
group by university
order by university

以下代码会编译出错:

select t.university,avg(t.answer_cnt)
from(
    select university,
        count(question_practice_detail.question_id) as answer_cnt
    from question_practice_detail
    join user_profile
    on question_practice_detail.device_id=user_profile.device_id
    group by question_practice_detail.device_id
)t
group by t.university