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
Can a commit statement be executed as part of a trigger?
What is a field in a database?
What is the difference between left outer join and left join?
Does db2 use sql?
What is pl sql code?
How can you fetch common records from two tables?
What do you mean by stored procedures? How do we use it?
Why trigger is used in sql?
Is like operator in sql case sensitive?
What does plv msg allows you to do?
Can you selectively load only those records that you need? : aql loader
Is left join inner or outer?
What is pls integer?
What are the different ddl commands in sql?
What is column?