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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 2nd max salary from employes table

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-03-10 : 09:22:28
Ranga writes "Hi there,

In one of my interview, i was asked how to select the 2nd max salary from emp table OR Nth max salary or Nth min salary. Below is code to construct a simple Emp table. Please let me know.

----------------------------
Create table #Emp
(
Empid int,
Salary Money
)

insert into #Emp(Empid, Salary) values (1,1000)
insert into #Emp(Empid, Salary) values (1,2000)
insert into #Emp(Empid, Salary) values (1,3000)
insert into #Emp(Empid, Salary) values (1,4000)
insert into #Emp(Empid, Salary) values (1,5000)

select * from #Emp
------------------------------

Thanks,
Ranga"
   

- Advertisement -