Can any one explain the below query for getting the 3 maximum salaries?
select distinct sal
from emp a
where 3 >= (select count(distinct sal)
from emp b
where a.sal <= b.sal)
order by a.sal desc;
Someone suuggested to me the use of the above query to get 3 max. salaries in a table. I didn't understand what is happening in the below part of the query:
3>= (select count(distinct sal)
from emp b
where a.sal <= b.sal) ;
Can anyone explain it? if there is any other way to get the same result,please advice me with query