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
Which is better join or inner query?
What is the current version of sql?
Are subqueries faster than joins?
how can we destroy the cookie? : Sql dba
Why is a trigger used?
What has stored procedures in sql?
How do you update f as m and m as f from the below table testtable?
Why do we use subquery?
How many joins can you have in sql?
what are sequences
What is the purpose of a sql?
What is the difference between sql and mysql?
How many types of sql are there?
What is before trigger?
What is mutating trigger?