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 / neo

select t1.empno, deptno, sal from emp t1 where t1.sal =
(select max(t2.sal) from emp t2 where t1.deptno = t2.deptno
group by deptno)
union
select t1.empno, deptno, sal from emp t1 where t1.sal =
(select max(t2.sal) from emp t2
where t2.sal < (select max(t3.sal) from emp t3 where
t3.deptno = t2.deptno and t1.deptno = t2.deptno )
group by deptno)
order by deptno, sal desc;

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is text? : Sql dba

1058


What is clustered index in sql?

1040


What pl/sql package consists of?

1059


What plvcmt and plvrb does in pl/sql?

1294


What are sql data types?

998


Is sql a backend language?

1075


Is clustered index a primary key?

931


What is the usage of nvl function?

1024


What is the use of <> sql?

960


Which is faster joins or subqueries?

972


what are numeric data types? : Sql dba

1047


Why do we need view in sql?

968


What is data types in sql?

982


How to avoid using cursors?

1099


What is varchar data type in sql?

1061