Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
SanjaySutar
Starting Member
18 Posts |
Posted - 2008-04-09 : 06:59:29
|
| How to find out 2nd highest salary using sql?thanx in advance |
|
|
elancaster
A very urgent SQL Yakette
1208 Posts |
Posted - 2008-04-09 : 07:13:18
|
| did your teacher give you any sample data?Em |
 |
|
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2008-04-09 : 07:41:03
|
| DECLARE @employee TABLE ( empid INT IDENTITY(1,1), ename VARCHAR(30), EMPSAL BIGINT)INSERT INTO @employee VALUES('RAJA',50000)INSERT INTO @employee VALUES('RAVI',60000)INSERT INTO @employee VALUES('RAMU',15000)INSERT INTO @employee VALUES('SURESH',8000)INSERT INTO @employee VALUES('MOHAN',15000)--SELECT * FROM @employeeSELECT EMPSAL FROM ( SELECT ROW_NUMBER() OVER (ORDER BY EMPSAL DESC)AS 'ROWNO',EMPSAL FROM @employee ) EWHERE E.ROWNO = 2THIS WORKS WELL IF YOU ARE USING SQL SERVER 2005 |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|