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 a trigger? : Sql dba
What are sql functions? Describe the different types of sql functions?
What are different types of triggers?
What is difference between table and view?
How do I copy a table in sql?
Is sqlite thread safe?
What are the string functions in sql?
what is sp_pkeys? : Transact sql
How to convert comma separated string to array in pl/sql?
Can we create index on primary key?
What is crud stand for?
what is transaction? : Sql dba
What is cartesian join in sql?
Can we use ddl statements in stored procedure?
How do you select unique values in sql?