WITH 학생성적 AS ( SELECT 1 학번, 2023 년도, 2 학기, 1 과목, 100 점수 FROM dual UNION ALL SELECT 2, 2023, 2, 1, 90 FROM dual UNION ALL SELECT 3, 2023, 2, 1, 80 FROM dual UNION ALL SELECT 4, 2023, 2, 1, 80 FROM dual UNION ALL SELECT 5, 2023, 2, 1, 80 FROM dual UNION ALL SELECT 6, 2023, 2, 1, 70 FROM dual UNION ALL SELECT 7, 2023, 2, 1, 60 FROM dual UNION ALL SELECT 8, 2023, 2, 1, 60 FROM dual UNION ALL SELECT 9, 2023, 2, 1, 50 FROM dual UNION ALL SELECT 1, 2023, 2, 2, 90 FROM dual UNION ALL SELECT 2, 2023, 2, 2, 80 FROM dual UNION ALL SELECT 3, 2023, 2, 2, 70 FROM dual UNION ALL SELECT 4, 2023, 2, 2, 60 FROM dual ) SELECT 년도 , 학기 , 과목 , 학번 , 점수 , ROUND( ( RANK() OVER(PARTITION BY 년도, 학기, 과목 ORDER BY 점수 DESC) - 1 + ( COUNT(*) OVER(PARTITION BY 년도, 학기, 과목, 점수) - 1) / 2 ) / COUNT(*) OVER(PARTITION BY 년도, 학기, 과목) * 100, 2) AS 백분위 FROM 학생성적 ;