-5

How to find the row with 7th highest salary from employee table in MySQL? I have tried it this way but unable to get the exact query.

SELECT MAX(salary) FROM employee 
WHERE salary NOT IN 
      (SELECT MAX(salary) FROM employee)
Martin
  • 22,212
  • 11
  • 70
  • 132
Deepak Kumar
  • 221
  • 3
  • 17

4 Answers4

6

What a brief post!!! Try this though,

select *
from(
    select distinct salary
    from employee
    order by salary desc limit 7
) t
order by salary
limit 1
Blank
  • 12,308
  • 1
  • 14
  • 32
1

maybe you can use this

 SELECT * FROM employe ORDER BY salary DESC LIMIT 7

hope this will help you

Hatchwald
  • 300
  • 2
  • 13
0

I got the answer.

SELECT *
   FROM one one1
   WHERE ( 7 ) = ( SELECT COUNT( one2.salary )
                   FROM one one2
                   WHERE one2.salary >= one1.salary
                 )
Deepak Kumar
  • 221
  • 3
  • 17
0
SELECT *
FROM employees emp
WHERE 7 =
    (SELECT COUNT(DISTINCT salary)
     FROM employees
     WHERE emp.salary<=salary );
Ankit Jindal
  • 3,672
  • 3
  • 25
  • 37