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
Does sqlite need a server?
What is the difference between cross join and natural join?
What is using in sql?
Is it possible to update views?
Which are the different character-manipulation functions in sql?
Where is all the data on the internet stored?
how to include character strings in sql statements? : Sql dba
What is difference between rank () row_number () and dense_rank () in sql?
What is union, minus and interact commands?
What are sql procedures?
how to convert character strings to dates? : Sql dba
How does stored procedure reduce network traffic?
What is pl sql in dbms?
What is a procedure in pl sql?
What are keys in sql?