I have a table containing employid and salary. How can I find the employ with third highest salary.Please tell me
SELECT TOP 1 sal FROM <table>
WHERE sal not in
(SELECT TOP 2 sal FROM <table> group by sal order by (count(sal)) desc)
group by sal
order by (count(sal)) desc
If you have unique salaries, you can take out the group by and count. If you have any doubts about this query, post back.