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

how to retrieve the top 3 salaries of the table using rownum

Answer Posted / rajnish chauhan

you can put any number on Rnk.

---Top 3 salary
SELECT ROWNUM,ename,sal
FROM (
SELECT ename,sal,rank() over(ORDER BY sal DESC)rnk
FROM emp)a WHERE rnk<4

-----Top 3 Salary only
SELECT ROWNUM,ename,sal
FROM (
SELECT ename,sal,rank() over(ORDER BY sal DESC)rnk
FROM emp)a WHERE rnk=3

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is use of term?

1045


How do you drop a trigger?

967


Why is there a need for sqlcode and sqlerrm variables?

1029


What is a memo field?

946


what is data control language? : Sql dba

1003


what is the difference between rownum pseudo column and row_number() function? : Sql dba

1060


what are the differences between procedure-oriented languages and object-oriented languages? : Sql dba

1023


what is the difference between nested subquery and correlated subquery?

1028


What is the difference between inner join and left join?

972


What does an inner join do?

1160


Is it possible to link two groups inside a cross products after the cross products group has been created?

992


What is a variable in sql?

980


What is execution plan in sql?

1021


How can the performance of a trigger be improved?

1022


Do we need commit after truncate?

1063