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
explain the difference between delete , truncate and drop commands? : Sql dba
How do you declare a constant?
What is trigger and stored procedure in sql?
Write an sql query to select all records from the table?
what is a view? : Sql dba
What can you do with pl sql?
What is the difference between inner join and left join?
What are the two different parts of the pl/sql packages?
Why is partition used in sql?
What is a clob in sql?
What is a loop in sql?
what is the difference between rownum pseudo column and row_number() function? : Sql dba
What is the difference between an inner join and an outer join?
how can we destroy the session, how can we unset the variable of a session? : Sql dba
Difference between table function and pipelined function?