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?

Questions by satchin

Showing Answers 1 - 16 of 16 Answers

Shree

  • Mar 26th, 2006
 

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

  Was this answer useful?  Yes

Sivakumar

  • Sep 7th, 2006
 

Hi,

 This will solve your problem.

Use "select salary from emp a where 5 = (select count(distinct(salary)) from emp b where b.salary>= a.salary) "

Thanks & Regards,

Sivakumar

  Was this answer useful?  Yes

Rajeev

  • Feb 2nd, 2007
 

Select Max(Salary) from table_Name Where Salary Not IN (Select TOP 5 From Table_Name order by salary desc)

  Was this answer useful?  Yes

mukesh kumar tiwari

  • Apr 9th, 2007
 

select salary from tablename group by salary dsc limit 4,1;

  Was this answer useful?  Yes

SELECT *
FROM  (SELECT  ename ,sal,
                  dense_rank() over (ORDER BY sal DESC) max_sal
        FROM emp)
WHERE max_sal= 5;

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions