Limit results to the first 2 ranking rows
select * from (
SELECT Subject, Name, RANK() OVER (PARTITION BY Subject ORDER BY Score DESC) as RN
FROM Table
) a
where a.RN <= 2
You could put the original query using rank()
into a subquery and wrap it with a query that filters the results.