Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

Explain the creation and execution of a user-defined function in the sql server?

1051


Explain database normalization?

1229


What is Command line parameters in PLSQL.?

1132


What is create command?

974


Tell me what do we need queues in sql service broker?

995


How to list all user names in a database?

1058


What does it mean if @@cursor_row returns a negative number?

992


what's the difference between delete table and truncate table commands? : Sql server database administration

983


What is partitioned view?

900


how many layers of tcp/ip protocol combined of? : Sql server database administration

998


Can we update data in a view?

1034


How to generate create table script on an existing table in ms sql server?

1143


What is dbcc command in sql server?

1093


Do you know what are acid properties?

1080


What does man by sql wildcard characters in sql server?

1062