how to fetch top 20 rows : LUSENET : DBAzine : One Thread

Dear Sir/Madame, We are developing an application where a user wants to see the top 20 customer. I am having a table with customer_name, and balances. We want to see the top 20 customers. If i am writing query like this, then this is not fetching the correct records. How to get the top 20 records.

For example, I have the following:

select cust_name, balance from cust where rownum < 21 order by balance desc;

As we know that it assigned rownum based on the selection and then apply order by clause.

Waiting for quicker reply

Rajesh Jain

-- RK Jain (, August 10, 2002


please see the link below

-- basivi reddy inaganti (, August 27, 2002.

Moderation questions? read the FAQ