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
How to optimize stored procedure optimization?
How to provide default values to stored procedure parameters?
How retrieve field names from the table in SQL through JAVA code?
Explain indexed views?
If you want to send some data from access database to sql server database. What are different component of ssis will you use?
What are trace flags?
whats the maximum size of view state??
what is sql server? : Sql server database administration
Explain triggers in sql?
Write a SQL query to make a column as unique?
How you can get a list of all the table constraints in a database?
How to run queries with sql server management studio express?
Hi, I Created 3 Tables Person(PersID[prkey],Name,Email,Password), Project(ProjName,ProjID[prkey],ProjLeader,ProjManager) & ProjectInvolvement(EntryDate,ProjID[frkey],PersID[frkey],ProjDuration). For this how can i INSERT,UPDATE & DELETE Through PROCEDURE? Please Post the Answer for me. Desai.
What is explicit mode in sql server?
Explain what is raid and what are different types of raid levels?