题解 | 浙大不同难度题目的正确率

浙大不同难度题目的正确率

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

WITH x AS (
  SELECT
    qpd.device_id AS device_id,
    qpd.question_id AS question_id,
    qpd.result AS result,
    u.university AS university 
  FROM
    question_practice_detail qpd
    LEFT JOIN user_profile u ON u.device_id = qpd.device_id 
  WHERE
u.university = '浙江大学') SELECT
qd.difficult_level AS difficult_level,
sum(IF(x.result = 'right', 1, 0)) / sum(IF(x.result IN ('right', 'wrong'), 1, 0)) AS correct_rate 
FROM
  x
  LEFT JOIN question_detail qd ON x.question_id = qd.question_id 
GROUP BY
  difficult_level 
ORDER BY
  correct_rate

嵌套了一下外连接,内存占用比较多但是可以输出

全部评论

相关推荐

说又不是不能用的斑马...:把中学和居住地删了,很多私企歧视北京人。别写你炒股,hr觉得你炒股赚的比工资高多了,很有可能干不了几天就跑路专职炒股了。只要你不是找金融行业的,这就是个超级减分项
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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