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
• 6,260 points
83 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
• 5,040 points

Related Questions In Database

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,360 points
7,051 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
12,182 views
0 votes
2 answers

How to select the nth row in a SQL database table?

SELECT * FROM ( SELECT ID, NAME, ROW_NUMBER() ...READ MORE

answered Apr 23, 2020 in Database by anand
• 140 points
15,427 views
0 votes
1 answer

How to drop all tables from a database with one SQL query?

Use the INFORMATION_SCHEMA.TABLES view to get the ...READ MORE

answered Feb 4 in Database by Neha
• 6,260 points
92 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
• 6,260 points
867 views
0 votes
1 answer

Why is not preferable to use mysql_* functions in PHP?

The reasons are as follows: The MySQL extension: Does ...READ MORE

answered Sep 7, 2018 in Database by DataKing99
• 8,240 points
312 views
0 votes
1 answer

Find values in a comma separated string in a MySQL query

You can add commas to the left and ...READ MORE

answered Sep 10, 2018 in Database by Sahiti
• 6,360 points
11,230 views
0 votes
1 answer

How to do a batch insert in MySQL

You can try out the following query: INSERT ...READ MORE

answered Sep 10, 2018 in Database by Sahiti
• 6,360 points
1,632 views
0 votes
1 answer
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
• 5,040 points
35 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP