find salary [message #374737] |
Wed, 27 June 2001 09:12 |
m masoom
Messages: 8 Registered: June 2001
|
Junior Member |
|
|
sir,
i want 1st 5 maximum salary from emp table, then what should i do? pls reply me urgently
|
|
|
Re: find salary [message #374738 is a reply to message #374737] |
Wed, 27 June 2001 09:17 |
Jon
Messages: 483 Registered: May 2001
|
Senior Member |
|
|
You have to be more specific. If you have 2 people making $100000, 2 making $95000, 2 making $90000, 4 making $85000 and 7 making $80000, what would you want output?
|
|
|
Re: find salary [message #374805 is a reply to message #374737] |
Tue, 03 July 2001 16:21 |
Suresh
Messages: 189 Registered: December 1998
|
Senior Member |
|
|
1 .If you have index on salary field use this following sql
select /*+ index_desc(emp,<index_name>) */
empno,sal from emp
where rownum<6;
2. If you do not have index on sal field.
then
select empno,sal from emp a where 5>
(select count(*) from emp b where a.sal<b.sal)
/
|
|
|