please tell me the query to get details of the employee
having the second largest salary
Answer Posted / rathi
If we had a table named Employee which had a column named
Salary and we had to find the second highest Salary in the
Employee table, the query for the same would be:
SELECT TOP 1 Salary FROM (SELECT TOP 2 Salary FROM Employee
ORDER BY Salary DESC) AS E ORDER BY Salary ASC
The subquery or the inner query would return the top 2 rows
in descending Salary order which would be:
5000
4000
The outer query would then select the top 1 row from the
subquery results in ascending Salary order which would be:
4000
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
Explain the flow of creating a cube? : sql server analysis services, ssas
Explain full-text query in sql server?
How to insert and update data into a table with "insert" and "update" statements?
How can we improve performance by using SQL Server profiler?
What is difference between view and materialized view?
What is a rownum?
What are the rendering extensions of ssrs?
Does sql server use t sql?
How do you make a trace?
What is the maximum size of a row in sql server?
What is the difference between ‘having’ clause and a ‘where’ clause?
What is the usage of sign function?
What is database replication?
I have a table Events Events containing cardno,time,id,name--each id has a cardno my requirement is every day each employee swipe the card several times i want to calculate first and last time of each card the output should be name 1 2 6 7 in out in out holiday holiday xxx 09:30 06:30 09:40 06:45 where 1,2...... are dates for example january 1,2, etc. 6 and 7 are saturday and sunday how it is posssible
explain what are the steps you will take, if you are tasked with securing an sql server? : Sql server database administration