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 does := mean in pl sql?
What are the types of join and explain each?
What makes a good primary key?
What type of database is sql?
What is procedure explain with example?
What is basic structure of pl sql?
what are ddl statements in mysql? : Sql dba
What is a subquery in sql?
What is input buffer in sql*plus?
What port does sql server use?
how to shut down the server with 'mysqladmin'? : Sql dba
Why procedure is used in sql?
If i can use sys.check_constraints to display my constraints from my database using sql server 2005, how can i display then if i am using sql server 2000????
What is sql trigger example?
Is inner join same as self join?