难题丨又学到了各自排序怎么办

每个题目和每份试卷被作答的人数和次数

https://www.nowcoder.com/practice/203d0aed8928429a8978185d9a03babc?tpId=240&tags=&title=&difficulty=0&judgeStatus=0&rp=0&sourceUrl=%2Fexam%2Foj%3Ftab%3DSQL%25E7%25AF%2587%26topicId%3D240

当然是各自建表排好序再union组合起来

SELECT * FROM
(SELECT 
exam_id tid,
COUNT(DISTINCT uid)uv,
COUNT(*)pv
FROM
exam_record
GROUP BY exam_id
ORDER BY uv DESC,pv DESC)a
UNION
SELECT * FROM
(SELECT 
question_id tid,
COUNT(DISTINCT uid)uv,
COUNT(*)pv
FROM
practice_record
GROUP BY question_id
ORDER BY uv DESC,pv DESC)b
全部评论

相关推荐

10-14 13:25
已编辑
门头沟学院 C++
点赞 评论 收藏
分享
offer多多的六边形战士很无语:看了你的博客,感觉挺不错的,可以把你的访问量和粉丝数在简历里提一下,闪光点(仅个人意见)
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务