How do you retrieve the second highest salary from a table?
Answer Posted / nashiinformaticssolutions
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 check myisam tables for errors? : Sql dba
Are stored procedures faster than queries?
What is difference between nchar and nvarchar?
What is the difference between execution of triggers and stored procedures?
What is the purpose of design view?
Is the primary key an index?
Explain the the delete statements in sql?
How do you pronounce sql?
What is the left table in sql?
What is the difference between clustered and non-clustered indexes?
What is sql stand for?
Why is a trigger used?
What are analytical functions in sql?
What is a constraint? Tell me about its various levels.
What are the ddl commands?