create table #ime(num varchar(20),name varchar(20),sal int); insert into #ime values('1','kannan',10000); insert into #ime values('2','dinesh',2000); insert into #ime values('3','dinesh1',3000);
select * from (select num,name,sal,dense_rank()over(order by sal desc) rank from #ime) result where result.rank=2
select * from ( select name, dense_Rank() over(order by sal)as kk from #ime) as a where a.kk=2
select * from ( select *, row_number() over(order by sal desc) as rn from table name ) as sub where rn=2
DECLARE @ime table(num varchar(20),name varchar(20),sal int);INSERT INTO @ime values('1','kannan',10000),('2','dinesh',2000),('3','dinesh1',3000),('4','dinesh2',3000)SELECT name, sal, DENSE_RANK() OVER(ORDER BY sal) AS DR, ROW_NUMBER() OVER(ORDER BY sal) AS RNFROM @ime
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)