题解 | SQL24 统计每个用户的平均刷题数

这题和上题类似,但是考察了wherehaving的区别。

where是要在group by的前面,而having是出现在group by的后面。所以我们这里只能用having跟在group by的后面。

select 
university,
difficult_level,
count(q.question_id) / count(distinct q.device_id) as 'avg_answer_cnt'
from 
user_profile as u 
join question_practice_detail as q
on u.device_id = q.device_id

join question_detail as qd
on q.question_id = qd.question_id

group by university, difficult_level
having university = '山东大学';
全部评论

相关推荐

豆泥🍀:同26届,加油,我也还没找到查看图片
点赞 评论 收藏
分享
抱抱碍事梨a:三点建议,第一点是建议再做一个项目,把自我介绍部分顶了,第二点是中南大学加黑加粗,第三点是建议加v详细交流
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务