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
What is information schema in sql?
Is vs as in pl sql?
How to display the current date in sql?
What are sql indexes?
What are records give examples?
name 3 ways to get an accurate count of the number of records in a table? : Sql dba
What is sql procedures and functions?
Does sap use sql?
Explain table and field in sql?
When is a declare statement required?
What is java sql drivermanager?
What is the use of function "module procedure" in pl/sql?
What is trigger explain with example?
What are the advantages of sql?
What is faster join or subquery?