how to fetch top 20 rowsgreenspun.com : 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
-- RK Jain (email@example.com), August 10, 2002
please see the link below http://www.db2mag.com/db_area/archives/2001/q3/programmers.shtml
-- basivi reddy inaganti (firstname.lastname@example.org), August 27, 2002.