How to find the 5 th MAX Salary in sql server 2008



create table Employee2000 (eno int,ename varchar(30),Sal int );

insert into Employee2000 values (1,'ANIL',25000)
insert into Employee2000 values (2,'SUNIL',24000)
insert into Employee2000 values (3,'Rajesh',23000)
insert into Employee2000 values (4,'Kamesh',22000)
insert into Employee2000 values (5,'RUPESH',21000)










select sal from Employee2000 e1 where 4=(select COUNT(*) from Employee2000 f1 where e1.Sal<f1.Sal)



Comments

Popular posts from this blog

DBA - Check health and status of Always On or Availability Group using DMVs

DBA - Script out the Linked server objects.

SQLDBA_ Failover -Registry Check Pointing a Windows Cluster to Bring SQL Server Online