How do you retrieve the second highest salary from a table?
Answer Posted / glibwaresoftsolutions
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
Why is sql*loader direct path so fast?
What is view explain with example?
what is the difference between delete and truncate statement in sql? : Sql dba
Explain how you can copy a file to file content and file to pl/sql table in advance pl/sql?
What is forward declaration in pl sql?
How do I partition a table in sql?
Is progress software supports to ( pl/sql )?
what is a trigger in mysql? : Sql dba
How many indexes can be created on a table in sql?
What is the difference between microsoft sql and mysql?
How do sql triggers work?
Is record in oracle pl sql?
What are the different sql languages?
Which query operators in sql is used for pattern matching?
What is pivot in sql?