SELECT distinct id, name, score FROM(SELECT id, name, final_score as score, DENSE_RANK() over(order by final_score DESC) as rk FROM(SELECT id, name, jf+kf_new as final_score from(SELECT x.id, x.name, jf, IFNULL(kf,0) as kf_new FROM(SELECT id, name, sum(grade_num) over(partition by user_id) as jf fro...