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

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

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

运营想要计算一些参加了答题不同学校、不同难度的用户平均答题量,请你写SQL取出相应数据
#sql书写顺序:select···from···where···group by···having···order by···limit···  //以上语句不能颠倒
#sql执行顺序:from···where···group by···having···select···order by···limit···
select
  university,
  difficult_level,
  round(
    count(qpd.question_id) / count(distinct(qpd.device_id)),
    4
  ) as avg_answer_cnt
from
  question_practice_detail as qpd
  left join user_profile as up on qpd.device_id = up.device_id
  left join question_detail as qd on qd.question_id = qpd.question_id
where
  university = '山东大学'
group by
  difficult_level;


全部评论

相关推荐

03-01 19:30
已编辑
南京大学 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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