SELECT * FROM (SELECT t.*, RANK() OVER (PARTITION BY t.a ORDER BY t.b DESC) AS drank FROM table1 t) a WHERE drank=1