How do you retrieve the second highest salary from a table?
Answer Posted / hr@tgksolutions.com
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 the authentication modes in sql server? : Sql dba
How do you modify a table in sql?
Mention what problem one might face while writing log information to a data-base table in pl/sql?
What is record type in pl sql?
How do you use join?
What is a stored procedure in sql with example?
Can a procedure in a package be overloaded?
what is sql profiler? : Sql dba
What is sql clause?
Explain some predefined exceptions.
What is varchar sql?
Is pl sql useful?
how to write date and time literals? : Sql dba
what is a trigger in mysql? : Sql dba
What are the operators in sql?