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

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

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

select 
    s1.university,
    s3.difficult_level,
    round(count(s2.question_id)/count(distinct s2.device_id),4) as avg_answer_cnt
from user_profile as s1
inner join question_practice_detail as s2
on s1.device_id = s2.device_id and s1.university='山东大学'

inner join question_detail as s3
on s2.question_id = s3.question_id

group by s3.difficult_level,s1.university;


select 
    "山东大学" as university,
    difficult_level,
    count(qpd.question_id) / count(distinct qpd.device_id) as avg_answer_cnt
from question_practice_detail as qpd

inner join user_profile as up
on up.device_id=qpd.device_id and up.university="山东大学"

inner join question_detail as qd
on qd.question_id=qpd.question_id

group by difficult_level



/*
group by 后要排序n-1个字段,不排序则须如method2 将university设置成同一content
*/

全部评论

相关推荐

积极的小学生不要香菜:你才沟通多少,没500不要说难
点赞 评论 收藏
分享
风中翠竹:真的真的真的没有kpi。。。面试官是没有任何kpi的,捞是真的想试试看这个行不行,碰碰运气,或者是面试官比较闲现在,没事捞个人看看。kpi算HR那边,但是只有你入职了,kpi才作数,面试是没有的。
双非有机会进大厂吗
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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