SELECT * FROM ( SELECT T.*, ROW_NUMBER() OVER (PARTITION BY T.SUBJECT, T.CHARCODE ORDER BY T.SCORE DESC) AS RN FROM T_SCORE T ) WHERE RN <= 3
SELECT * FROM ( SELECT T.*, ROW_NUMBER() OVER (PARTITION BY T.SUBJECT, T.CHARCODE ORDER BY T.SCORE DESC) AS RN FROM T_SCORE T ) WHERE RN <= 3