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

select top 3 sal from each dept?

Answer Posted / divakarreddy

SQL> select *from (select ename,sal,deptno,rank()
2 over(partition by deptno order by sal desc)topsal
3 from emp)
4 where topsal<=3
5 order by deptno,sal desc;

ENAME SAL DEPTNO TOPSAL
---------- ---------- ---------- ----------
KING 5000 10 1
MILLER 3000 10 2
CLARK 2450 10 3
SCOTT 3000 20 1
JONES 2975 20 2
ADAMS 1100 20 3
BLAKE 2850 30 1
ALLEN 1600 30 2
TURNER 1500 30 3

9 rows selected.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is it possible to create startup or shutdown trigger for on-schema?

1042


what is the command used to fetch first 5 characters of the string? : Sql dba

1647


What are the types of keys?

1005


What is the difference between join and natural join?

937


What is the difference between left outer join and left join?

1007


What do we need to check in database testing?

1030


In pl/sql, what is bulk binding, and when/how would it help performance?

1007


What is mdb stand for?

1018


Which sql statement is used to return only different values?

1017


What are the main features of cursor?

1078


What does fetching a cursor do?

1097


what is a database transaction? : Sql dba

1194


What is data abstraction in sql?

1040


what are the different type of sql's statements ? : Sql dba

930


what is the use of double ampersand (&&) in sql queries?

1183