how to display only the first 3 rows
Please how can I write a query to display only the top three earners in a table in desc order e.g
Emp Sal
John 100
Jam 120
Abi 90
Jo 170
the query should display
Emp Sal
John 200
Jam 170
thanks
achiman
Junior Poster in Training
51 posts since Mar 2009
Reputation Points: 10
Solved Threads: 0
I have tried using numrow but it doesnt do the job
achiman
Junior Poster in Training
51 posts since Mar 2009
Reputation Points: 10
Solved Threads: 0
please is there any function called rank in oracle and how can i use it
achiman
Junior Poster in Training
51 posts since Mar 2009
Reputation Points: 10
Solved Threads: 0
rank does not work maybe because im using oracle8i
achiman
Junior Poster in Training
51 posts since Mar 2009
Reputation Points: 10
Solved Threads: 0
Try this
select * from emp where rownum<4 order by sal desc
debasisdas
Posting Genius
6,872 posts since Feb 2007
Reputation Points: 666
Solved Threads: 434
I hope this query also may help:
Select top(3) from emp order by sal DESC
You need to read question properly before answering to them. This is oracle forum not sql server.
debasisdas
Posting Genius
6,872 posts since Feb 2007
Reputation Points: 666
Solved Threads: 434