2nd highest Salary in SQL

Find 2nd Highest Salary and Nth Salary in SQL

select name, MAX(salary) as salary from Employee where salary < (select MAX(salary) from employee);


<!-- Nth row query  -->

SELECT * FROM (
  SELECT e.*, 
  ROW_NUMBER() OVER (ORDER BY salary DESC) as rn 
  FROM Employee e
)
WHERE rn = N;

0 Comments

Leave a reply

* Your email/mobile address will not be published. required fields are marked.

* Email and mobile number will be verified before publishing the comments.

Name *
Email *
Mobile