This is rather clever. I think you were missing a 'b'
select * from emp a
where 5=
(select count(distinct sal) from emp b <-- this was missing?
where a.sal>=b.sal)
Here is how it works .. taking some simple numbers
15 , 12 , 10 ,9 ,7 ,4 ,2
This matches the table with itself with >=
15 - 15 1 match
12 12 and 15 2 matches
10 10, 12, 15 3 matches
9 9, 10, 12, 15 4 matches
7 7,9,10,12,15 5 matches
so it's made this temp table from the inner match rule and a.sal of 7 has 5 distinct b.sals
Phil
But I think that this can return multiple rows if there's a tie at the 5th salary