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 is the difference between microsoft access and sql?

1023


How can you know that statistics should be updated?

1079


Can ddl statements be used in pl/sql?

1145


How do you add a column to a table?

1055


What are pl sql data types?

1013


What is scalar function in sql?

1040


What is rowtype?

1021


What are pl/sql cursors?

1049


Can a table have no primary key?

1064


What is the difference between clustered and non-clustered index in sql?

1016


Is it possible to pass parameters to triggers?

1103


How many types of triggers exist in pl/sql?

1073


What is over () in sql?

965


What is pl/sql table? Why is it used?

1045


What is an index in sql with example?

974