select student_id,class_id,score from (
select a.student_id,a.class_id,a.score,
dense_rank()over(partition by a.student_id order by a.score desc) rn
from my_test a) where rn =1
select b.student_id,b.class_id from (select student_id,max(score) max_score from test.my_test group by student_id) a join test.my_test b on a.student_id=b.student_id and a.max_score=b.score;