How to get the TOP N records?

From: Dante Tang <c8354710_at_comp.polyu.edu.hk>
Date: 15 Mar 2000 16:41:00 GMT
Message-ID: <01bf8e9c$af82f1e0$4f08849e_at_default>



[Quoted] [Quoted] I have a dealer table which contains dealer information including the dealer's credit limit. This table contains 10 tuples and the tuples is not sorted by the credit limit.

How can I select 5 dealers whom has the first 5 top credit limit? I have tried the to include a rownum condition in the SQL. However, it does not work well. So I select the rownum and see what it is. I'm so surprise to discover that the rownum means the internal storage record number in the table. So it does not help in any means for my objective.

Do you have any good idea on doing my tasks? Please give me a hand. Thanks~

select rownum, d_credit_limit
from dealer
where rownum <= 10
order by d_credit_limit desc;

    ROWNUM D_CREDIT_LIMIT
---------- --------------

         9         210000
         5          34000
         2          20000
         8          15000
         1          10000
        10          10000
         6          10000
         7          10000
         3          10000
         4           8700
-- 
e-mail : c8354710_at_comp.polyu.edu.hk
URL : http://www.comp.polyu.edu.hk/~c8354710 
Received on Wed Mar 15 2000 - 17:41:00 CET

Original text of this message