-
Junior Member
How to get 6th heghest salary?
In SQL Server 2005, How to get 6th highest salary from a table?
Regards,
Prashanth Chenna.
-
Contributing Member
Re: How to get 6th heghest salary?
There are already few posts for ur question. You can get your reply from here
http://http://www.geekinterview.com/...st-salary.html
---V V---
Vikas Vaidya
-
Contributing Member
Re: How to get 6th heghest salary?
You can use the Query as fallowed
SELECT * FROM T1 WHERE n=
(SELECT COUNT(DISTINCT ) FROM T2 WHERE T1. <=T1.)
where 'n' is the nth highest value for the in the .
-
Junior Member
Re: How to get 6th heghest salary?
select top 1 salary
from (select distinct top 6 salary from employee order by salary desc) a
order by salary
-
Contributing Member
Re: How to get 6th heghest salary?
Hi jrameshvjr,
your query will give the only one record, if there are many number of employees holding the same salary then it won't be applicable..
-
Junior Member
Re: How to get 6th heghest salary?
select * from emp where salary not in (select distinct top n-1 salary from emp order by salary desc)
n=number of highest salary
-
Junior Member
Re: How to get 6th heghest salary?
select top 1 emp_salary from (select top 6 emp_salary from tblemployee order by emp_salary desc) a order by emp_salary asc
-
Junior Member
Re: How to get 6th heghest salary?
select top(6) from tablename,but this will not applicable where there more number of employees drawing the same salary? it includes duplicate rows
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules