How do you retrieve the second highest salary from a table?
Answer Posted / hr@tgksolutions.com
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 we use ddl statements in stored procedure sql server?
What is difference between sql and mysql?
what is data manipulation language? : Sql dba
How to handle bulk data?
What is sql*loader and what is it used for? : aql loader
What is the use of index in sql?
what are the different type of sql's statements ? : Sql dba
how can we know the number of days between two given dates using mysql? : Sql dba
What is a parameter query?
what is heap table? : Sql dba
How to select all records from the table?
What is sql used for?
What is raw datatype in sql?
What is trigger explain with example?
What is thread join () in threading?