select * from ( select id,name,score,date,ROW_NUMBER() over(PARTITION by name order by score desc,date desc) as num from tablename ) T where T.num <= 1 order by name