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
How to fetch alternate records from a table?
What are analytical functions in sql?
what is the difference between group by and order by in sql? : Sql dba
Does sql use python?
What is trigger in pl sql with examples?
Is it possible to link two groups inside a cross products after the cross products group has been created?
What do you understand by case manipulation functions?
What is compiled query?
Is primary key clustered index?
How do I start sql from command line?
How do I partition a table in sql?
what are myisam tables? : Sql dba
Enlist the advantages of sql.
State few characteristics of pl/sql?
What is the use of %rowtype?