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
What are the types of queries in sql?
How many triggers can be applied on a table?
What is a recursive stored procedure?
what are the differences between char and varchar? : Sql dba
Can a table contain multiple foreign key’s?
What are the sql versions?
How do you declare a constant?
Name some usages of database trigger?
what is 'mysqld'? : Sql dba
How do I run a sql script?
what is offset-fetch filter in tsql? : Transact sql
What is sql injection vulnerability?
What is the source code of a program?
How do you change a value in sql?
Explain the uses of control file.