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


what is syntex second or third highest salary.


thanks & Regards
Dhirendra sinha

Answers were Sorted based on User's Feedback



what is syntex second or third highest salary. thanks & Regards Dhirendra sinha..

Answer / sagar dhande

select top 2(salary) from (select top 3 (salary) from
dbo.employee order by salary desc)
order by salary

Is This Answer Correct ?    3 Yes 1 No

what is syntex second or third highest salary. thanks & Regards Dhirendra sinha..

Answer / praveen singh

select min(salary) from salary where salary in(select top 3
salary from salary order by salary desc)

Is This Answer Correct ?    3 Yes 2 No

what is syntex second or third highest salary. thanks & Regards Dhirendra sinha..

Answer / satish

select max(sal) from emp e1 where 1< (select count(distinct sal) from emp e2 where e1.sal <= e2.sal)

To make it generic if u want N'th highest salary;

select max(sal) from emp e1 where (N-1)< (select count(distinct sal) from emp e2 where e1.sal <= e2.sal)

And to get the N'th min sal :

select min(sal) from emp e1 where (N-1)< (select count(distinct sal) from emp e2 where e1.sal >= e2.sal)

Is This Answer Correct ?    1 Yes 0 No

what is syntex second or third highest salary. thanks & Regards Dhirendra sinha..

Answer / veeresh kethari

with Topsal (EmpID,Ename,Sal,Dno,Topsal) as
(select *,row_number() over(order by sal) Topsal from emp)
select top 2 EmpID,Ename,Sal,Dno from Topsal order by sal desc

Is This Answer Correct ?    1 Yes 0 No

what is syntex second or third highest salary. thanks & Regards Dhirendra sinha..

Answer / vikas kant

---To get 2nd highest salary----

select Top 1 salary from Emp where marks in(select top 2
salary from Emp order by salary desc)

---To get 3rd highest salary----

select Top 1 salary from Emp where marks in(select top 3
salary from Emp order by salary desc)



Regards Vikas Kant

Is This Answer Correct ?    0 Yes 0 No

what is syntex second or third highest salary. thanks & Regards Dhirendra sinha..

Answer / anil tiwari

select Top2(salery)from (select Top3 (salery) from tab1
order by salery DESC)order by salery.

Is This Answer Correct ?    0 Yes 0 No

what is syntex second or third highest salary. thanks & Regards Dhirendra sinha..

Answer / dipti saxena

select sal,rownum from (select sal from emp
order by sal desc)
where rownum<=3
MINUS
select sal,rownum from (select sal from emp
order by sal desc)
where rownum<=1

Is This Answer Correct ?    0 Yes 4 No

Post New Answer

More SQL Server Interview Questions

When do u use clustered index and non-clustered index?

3 Answers   IBM,


Explain what is lock escalation and what is its purpose?

0 Answers  


Define candidate key, alternate key, and composite key.

0 Answers  


Can sql servers link to other servers like oracle?

0 Answers  


Let us say the SQL Server crashed and you are rebuilding the databases including the master database what procedure to you follow?

2 Answers  


How can you tell if a database object is invalid?

0 Answers   MCN Solutions,


How to delete an existing row with delete statements in ms sql server?

0 Answers  


what is hash table

3 Answers   ILFS, Teledata,


Give me any three differences between Truncate and Delete.

0 Answers   Genpact,


Can you explain what is the use of custom fields in report?

0 Answers  


How do I compare two values when one value(data type) is char and the other is an integer?

3 Answers  


Define master database?

0 Answers  


Categories