时间:2021-07-01 10:21:17 帮助过:29人阅读
提取表中每个分组的前几条数据 SELECT 课程, SUM(奖金) AS 奖金 FROM ( SELECT 课程, 学号, 成绩 FROM 考试 AS a WHERE ( SELECT COUNT(*) FROM 考试 WHERE 课程 = a.课程 AND 学号 a.学号 AND 成绩 a.成绩 ) 3 www.2cto.com ) AS b GROUP BY 课程
提取表中每个分组的前几条数据
SELECT 课程,
SUM(奖金) AS 奖金
FROM ( SELECT 课程,
学号,
成绩
FROM 考试 AS a
WHERE ( SELECT COUNT(*)
FROM 考试
WHERE 课程 = a.课程
AND 学号 <> a.学号
AND 成绩 > a.成绩
) < 3 www.2cto.com
) AS b
GROUP BY 课程