How to find the employee who get seventh largest salary in the company?

Questions by mithrz

Showing Answers 1 - 24 of 24 Answers

Bala

  • Aug 25th, 2012
 

Code
  1.  

  2. SELECT salary FROM

  3. (SELECT salary, dense_rank() over (ORDER BY salary)

  4. FROM emp)

  5. WHERE dense_rank = 7;

  6.  

  Was this answer useful?  Yes

gowtham

  • Oct 1st, 2012
 

select salary data only

  Was this answer useful?  Yes

Amninder

  • Apr 15th, 2013
 

Select emp_id,emp_name,salary from employee a,
(Select salary,dense_Rank() over (order by salary DESC) rank_sal from employee)b
where a.salary=b.salary
and rank_sal=7;
The Inline Query will order salary by descending order and will correspondingly rank them, and by joining the salary present at 7th number with the main table, we can find the required data.

  Was this answer useful?  Yes

dinesh

  • Jul 23rd, 2013
 

Code
  1.  SQL>SELECT DISTINCT SAL FROM EMP E WHERE 7>=(SELECT COUNT (DISTINCT SAL) FROM EMP A WHERE A.SAL>=E.SAL) ORDER BY SAL DESC

  Was this answer useful?  Yes

jamakucky

  • Jan 5th, 2015
 

Code
  1. SELECT emp_name,salary

  2. FROM employee

  3. WHERE salary = (

  4. SELECT DISTINCT salary

  5. FROM employee

  6. ORDER BY salary DESC

  7. OFFSET 6 ROWS FETCH NEXT 1 ROWS ONLY)

  Was this answer useful?  Yes

obaid

  • Jan 7th, 2015
 

Select top(7) salary from employee where order by salary desc

  Was this answer useful?  Yes

Nikita Patil

  • Jan 11th, 2015
 

SELECT ENAME FROM (SELECT * FROM EMP ORDER BY SAL DESC )
WHERE ROWNUM<=7
MINUS
SELECT ENAME FROM (SELECT * FROM EMP ORDER BY SAL DESC )
WHERE ROWNUM<=6;

  Was this answer useful?  Yes

Binod

  • May 26th, 2015
 

SELECT MIN(SALARY) FROM
(SELECT DISTINCT SALARY FROM EMPLOYEE
ORDER BY SALARY DESC)
WHERE ROWNUM<=7;

  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