Which SQL query is used to find Nth highest salary from a salary table

0 votes
Can someone please help me to find out nth highest salary from the salary table in MYSQL?
Feb 14 in Database by Neha
• 8,940 points
681 views

1 answer to this question.

0 votes

If you want to find nth Salary from a table where n can be any number,

Query for finding the nth Salary:

SELECT DISTINCT Salary FROM tblemployees ORDER BY Salary DESC LIMIT 1 OFFSET (n-1)

If you want to find 5th highest salary, your query should look like :

SELECT DISTINCT Salary FROM tblemployees ORDER BY Salary DESC LIMIT 1 OFFSET 4

Note: OFFSET starts from 0th position, and hence use N-1 rule here

answered Feb 14 by Vaani
• 7,020 points

Related Questions In Database

0 votes
0 answers
0 votes
1 answer

What is the SQL query to get the third highest salary of an employee from employee_table

You can try out something like this: SELECT ...READ MORE

answered Sep 27, 2018 in Database by Sahiti
• 6,380 points
7,879 views
0 votes
0 answers

How to create a table from select query result in SQL Server 2008

I tried to build a table from ...READ MORE

Sep 2 in Database by Kithuzzz
• 20,660 points
90 views
0 votes
2 answers

Write a SQL query to find the names of employees that begin with ‘S’

Select ename From emp Where ename like"s%"; READ MORE

answered Oct 7, 2021 in Database by anonymous
16,139 views
0 votes
1 answer

SQL query to find third highest salary in company

The easiest way to work this out ...READ MORE

answered Feb 21 in Database by Neha
• 8,940 points
9,291 views
0 votes
0 answers

Creating a search form in PHP [duplicate]

I am working on a function where ...READ MORE

Jun 9 in PHP by Kichu
• 19,040 points
49 views
0 votes
0 answers

How do I list all the columns in a table?

For the various popular database systems, how ...READ MORE

Aug 9 in Database by Kithuzzz
• 20,660 points
45 views
0 votes
0 answers

How to convert date into timestamp in SQL query?

I'm attempting to move data from the ...READ MORE

Aug 19 in Database by Kithuzzz
• 20,660 points
194 views
0 votes
1 answer

How would I find the second largest salary from a employee table? [closed]

To find the 2nd largest salary from ...READ MORE

answered Feb 8 in Database by Vaani
• 7,020 points
128 views
0 votes
1 answer

How do I UPDATE from a SELECT in SQL Server?

MERGE INTO YourTable T USING ...READ MORE

answered Feb 3 in Database by Vaani
• 7,020 points
167 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP