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...

I Have Employee table having column name as ID,SALARY
how to get second max salary from employee table with id
ex
ID SALARY
1 20000
7 37000
2 5000

Answer Posted / chan

SELECT ID, SALARY FROM
(
SELECT ID, SALARY, ROW_NUMBER() OVER (ORDER BY SALARY) AS RN
FROM EMPLOYEE
)
WHERE RN = 1

(YOU CAN CHANGE VALUE OF RN = ANY NUMBER AND YOU WILL GET
THAT VALUE)

Is This Answer Correct ?    3 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the differences between having and where clause.

1023


what is a correlated sub-query? : Sql server database administration

992


Does full backup break log chain?

1016


You want to use a perspective in an mdx query. How do you select the perspective?

246


Which command is used for user defined error messages?

1105


How to connect to SQL Azure Database by using sqlcmd?

140


What are the differences between “row_number()”, “rank()” and “dense_rank()”?

1253


What is cursors?

1262


What is a with(nolock)?

1027


What are pages and extents? : SQL Server Architecture

1073


How to delete duplicate rows?

1039


Where are stored procedures in sql server?

1129


What is the difference function and stored procedure?

1116


What is unpivot?

1077


Define candidate key, alternate key, and composite key.

969