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

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

https://www.nowcoder.com/practice/f4714f7529404679b7f8909c96299ac4

解析:
此题和上一道题类似,题意,参加了答题的山东大学的用户在不同难度下的平均答题题目数
1.参加了答题的山东大学的用户:
就意味着不需按照大学去分组,只需要按照难度进行分组,在条件判断中去判断 university ='山东大学'即可
2.不同难度: 按照难度进行分组group by t3.difficult_level
3.平均答题题目数 :山东大学的参与答题的人数 和总题目数
人数:count(distinct device_id)过滤分组后人数就只有山东大学的
题目数:count(question_id)
select 
t1.university as university,
t3.difficult_level as difficult_level,
round(count(t2.question_id) / count(distinct t2.device_id),4) as avg_answer_cnt
from 
user_profile as t1,
question_practice_detail as t2,
question_detail as t3
where 
t1.device_id = t2.device_id 
and t1.university = '山东大学'
and t2.question_id = t3.question_id
group by t3.difficult_level;


全部评论

相关推荐

评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务