select university,difficult_level,round(count(qpd.question_id) / count(distinct qpd.device_id),4) from user_profile as up,question_practice_detail as qpd,question_detail as qd where up.device_id=qpd.device_id and qpd.question_id=qd.question_id and university='山东大学' group by qd.difficult_level
我们知道,sql语句的执行顺序是:
from
where
group by
having
select
order by
limit
根据题意:'运营想要查看参加了答题的山东大学的用户在不同难度下的平均答题题目数'
首先是个多表联查的问题,然后不同难度则需要分组