RE: How to get fifth maximum salary from the table wit...
This should work:select max(emp_salary) from emp e1 where (select count(emp_salary) from emp e2 where e2.emp_salary>=e1.emp_salary)=5However if you want to display the corresponding employee info like first name or so,....I suggest using top keyword, as follows:select top 1 emp_name, emp_salary from emp where emp_name != (select top 1 emp_name from emp order by emp_salary desc) order by emp_salary desc
RE: How to get fifth maximum salary from the table with out using TOP keywork(without any keywords) in sql server 2000Can you please guide me about this?
SELECT * FROM (SELECT ename ,sal, dense_rank() over (ORDER BY sal DESC) max_sal FROM emp) WHERE max_sal= 5;
RE: How to get fifth maximum salary from the table with out using TOP keywork(without any keywords) in sql server 2000Can you please guide me about this?
select sal from emp e where 4=(select count(distinct(sal) from emp where sal>e.sal)