Write a query to get 2nd maximum salary in an employee table ?
Answer Posted / ahamed
The following solution is for getting 6th highest salary
from Employee table ,
SELECT TOP 1 salary
FROM (
SELECT DISTINCT TOP 6 salary
FROM employee
ORDER BY salary DESC) a
ORDER BY salary
or
SELECT MIN(Sal) FROM TableName
WHERE Sal IN
(SELECT TOP 6 Sal FROM TableName ORDER BY Sal DESC)
Reference:
http://blog.sqlauthority.com/2008/04/02/sql-server-find-nth-highest-salary-of-employee-query-to-retrieve-the-nth-maximum-value/
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is foreign key sql?
Is oracle sql free?
what are the differences between require and include, include_once and require_once? : Sql dba
explain normalization concept? : Sql dba
What is out parameter used for eventhough return statement can also be used in pl/sql?
What are sql commands?
How do I run sql profiler?
Is ms sql traffic encrypted?
How do I run a sql query in pgadmin 4?
what is row? : Sql dba
What is dbo in sql?
What is a table partition?
how to select unique records from a table? : Sql dba
Why query optimization is needed?
How many types of cursors are available in pl/sql?