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

i need department wise top 2 employees salary.which logic
i will use

Answer Posted / nag

select distinct(sal), deptno from
(select * from emp a where 1 = (select count(distinct sal)+1
from emp b where b.sal > a.sal and b.deptno = a.deptno) and
deptno is not null
union
select * from emp a where 2 = (select count(distinct sal)+1
from emp b where b.sal > a.sal and b.deptno = a.deptno)and
deptno is not null)
order by deptno,sal

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the 3 types of behavioral triggers?

1313


how many tables will create when we create table, what are they? : Sql dba

1118


What is a pdo connection?

1115


what is top in tsql? : Transact sql

1171


What are the advantages of indexing?

1026


How can I change database name in sql?

1157


Explain what is a field in a database and record in a database?

1180


What is the order of sql select?

1088


what are the differences between binary and varbinary? : Sql dba

1085


what is self join and what is the requirement of self join? : Sql dba

1191


What is the current version of sql?

1069


Explain how exception handling is done in advance pl/sql?

1046


what does the t-sql command ident_current does? : Transact sql

1048


How do you determine the current isolation level? : Transact sql

1206


Why cannot I use bind variables in ddl/scl statements in dynamic sql?

1265