C# Corner
Tech
News
Videos
Forums
Trainings
Books
Events
More
Interviews
Jobs
Live
Learn
Career
Members
Blogs
Challenges
Certifications
Bounties
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Find nth Salary Without Using Max or Top In SQL
WhatsApp
Pankaj Pandey
6y
118.5
k
0
6
25
Blog
Here I am writing SQL query to find nth salary without using top or max keywords.
SELECT
*
FROM
(
SELECT
ROW_NUMBER() OVER (
ORDER
BY
SALARY
DESC
)
AS
rownumber,Salary
FROM
Employee )
AS
foo
WHERE
rownumber = n
Example:
SELECT
*
FROM
(
SELECT
ROW_NUMBER() OVER (
ORDER
BY
SALARY
DESC
)
AS
rownumber,Salary
FROM
Employee )
AS
foo
WHERE
rownumber = 5
The above query will show 5th highest salary from Employee table.
Here is a free eBook,
SQL Queries for Beginners
People also reading
Membership not found