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

Can we use ddl commands in pl sql?

1066


What is embedded sql with example?

984


What is the purpose of primary key?

964


Can we use ddl statements in stored procedure sql server?

964


How to rename a column in the output of sql query?

997


what are the t string functions available in tsql? : Transact sql

944


What types of commands can be executed in sql*plus?

1048


Explain what is a subquery ?

1118


Can you selectively load only those records that you need? : aql loader

983


How many types of functions are there in sql?

892


Which join is like an inner join?

946


Is it possible for a table to have more than one foreign key?

968


Lookups are a key component in sql server integration services (ssis). Explain its purpose?

952


Can I join the same table twice?

991


differentiate between float and double. : Sql dba

988