I am writhing a query that will be helpful in finding nth salary and his id of that record.
so its very simple and very understandable.......
select ID ,salary from testing where salary in(select MIN(salary) from testing where
salary in (select top 4 salary from testing order by salary desc))
Here, First we find the nth salary from the table in decreasing order and then we select min salary from that records means from it sub query.
and then can fetch id ,salary of the table from the sub query result as u seeing in query.
so its very simple and very understandable.......
select ID ,salary from testing where salary in(select MIN(salary) from testing where
salary in (select top 4 salary from testing order by salary desc))
Here, First we find the nth salary from the table in decreasing order and then we select min salary from that records means from it sub query.
and then can fetch id ,salary of the table from the sub query result as u seeing in query.
if you are unable to understand then please drop a comment at below..............
or mail me at Kushwaha.pankajkumar07@gmail.com
No comments:
Post a Comment