how to find nth highest salary
Answer Posted / eldho k scaria
There are two methods:(Suppose table name is EMPLOYEE,
Colomn name is SALARY, and N=6)
SELECT * FROM EMPLOYEE
WHERE SALARY IN
(SELECT TO 1 SALARY (SELECT DISTINCT TOP 6 SALARY FROM
EMPLOYEE ORDER BY SALARY DESC)
A ORDER BY SALARY)
or
SELECT * FROM EMPLOYEE E1
WHERE (6-1)=(SELECT COUNT (DISTINCT (E2.SALARY))
FROM EMPLOYEE E2
WHERE E2.SALARY>E1.SALARY)
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
When you use @@error and try-catch?
What is microsoft sql server?
What is the command used to recompile the stored procedure at run time?
What new data source types were added in ssrs 2014?
Difference between primary key and clustered index?
Can group functions be mixed with non-group selection fields in ms sql server?
How except clause is differs from not in clause?
Is it true that rules do not apply to data already existing in a database at the time the rule is created?
Explain the properties of a relational table?
What is a data source or ds? : sql server analysis services, ssas
Explain different types of collation sensitivity?
Can you get second highest salary from the table?
Describe in brief system database.
Can another user execute your local temporary stored procedures?
What is primary key and example?