How do you retrieve the second highest salary from a table?
Answer Posted / nashiinformaticssolutions
Using a subquery:
SELECT MAX(salary)
FROM employees
WHERE salary < (SELECT MAX(salary) FROM employees);
Using ROW_NUMBER():
SELECT salary
FROM (
SELECT salary, ROW_NUMBER() OVER (ORDER BY salary DESC) AS row_num
FROM employees
) ranked
WHERE row_num = 2;
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What are joins in sql?
How do I debug a stored procedure?
Is mariadb a nosql database?
Is pl sql different from sql?
What are the benefits of triggers?
What are the two different parts of the pl/sql packages?
How to create an array in pl/sql?
what is the difference between undefined value and null value? : Sql dba
What is the maximum size of sqlite database?
How do I upgrade sql?
What mean sql?
State some properties of relational databases?
What is left join in postgresql?
How do I run a sql trace?
Is sql dba a good career? : SQL DBA