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
explain access control lists. : Sql dba
Is not null in sql?
what is sub-query? : Transact sql
Is join same as left join?
Is sql dba a good career? : SQL DBA
What is vector point function?
what are the maximum number of rows that can be constructed by inserting rows directly in value list? : Transact sql
What do you mean by dbms? What are its different types?
Is t sql a programming language?
What is bulk compiling in pl/sql.?
What are the types of join in sql?
What are the two types of exceptions.
Why do we create views in sql?
how to enter binary numbers in sql statements? : Sql dba
Which normal form is best?