SELECT * FROM ( SELECT 학년학기, 점수, RANK() OVER(PARTITION BY 학년학기 ORDER BY score DESC) AS 학년학기점수순위 FROM 테이블명 GROUP BY 학년학기, 점수 ) WHERE 학년학기점수순위 <= 5
RANK는 ANSI/ISO 표준, http://wiki.gurubee.net/pages/viewpage.action?pageId=27427796
Oracle에서는 아래와 같이 하면 되는데 sql lite는 rank()나 row_number()가 없으니
어떻게 처리해야할지 도저히 답이 안나오네요
select * from ( select Name 성명, selescnm 전형구분, examNumber 수험번호, a.SocialNumber 주민번호, Year 연도, grade 학년, term 학기, Subjectname 과목명, Unit 이수단위, StudentCount 학생수, OriginalScore 원점수, AvgScore 평균, RankingGrade 등급 ,row_number() over (partition by examNumber, term order by term, rankingGrade, unit desc) rnk from PersonalInfo a, SubjectScore b where a.mogib1 = b.mogib1 and a.mogib2 = b.mogib2 and a.schoolcode = b.schoolcode and a.SocialNumber = b.SocialNumber and b.grade = 2 and RankingGrade <= '9' ) where rnk <=5