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 the difference between clustered and non-clustered indexes?
List and explain the different types of join clauses supported in ansi-standard sql?
What does desc stand for?
Is oracle sql free?
What are the steps for performance tuning.
What are local and global Indexes and where they are useful.
Is sqlite good enough for production?
What are different categories of sql commands?
What is blind sql injection?
Is there a pl/sql pragma similar to deterministic, but for the scope of one single sql select?
Does sql*plus also have a pl/sql engine?
What is bind reference and how can it be created?
What are the types of variables use in pl sql?
What are triggers in sql?
What is secondary key?