1,617
社区成员
发帖
与我相关
我的任务
分享
WITH tmp_table AS
(
SELECT T.SCOREID,
T.COURSE,
T.SCORE,
T.STUDENTID,
ROW_NUMBER() OVER(PARTITION BY T.COURSE ORDER BY T.SCORE DESC) AS RN
FROM SCORE T
)
SELECT
ta.SCOREID,
ta.COURSE,
ta.STUDENTID,
ta.SCORE
FROM
tmp_table ta
WHERE
ta.rn = 1
select t.* from score t where score = (select max(score) from score where course = t.course)
select t.* from score t where not exists (select 1 from score where course = t.course and score > t.score)