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

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

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

select university,
difficult_level,
count(qpd.question_id)/count(distinct(qpd.device_id))
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 qpd.question_id = qd.question_id
where university = '山东大学'
group by difficult_level


# sql语句的书写顺序:
# select >> from >> where >> group by >> having >> order by >> limit
# 注意:
# 1. select和from是必须的;
# 2. where和having不能同时使用;
# 3. having和group by联合使用;

# sql语句的解析顺序 :
# from >> on>> join >> where >> group by >> having >> select >> distinct >> order by >> limit
# 注意:虽然select在having后执行,但是mysql中仍然可以在having中使用select语句定义的别名

#sql#
全部评论

相关推荐

代码不跑我跑_秋招版:北大杀完9✌杀,9✌杀完鼠鼠杀
你最希望上岸的公司是?
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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