How to get the 20 MOST and LEAST profitable customers from an OLEdb into Listboxes 1

piscis

Well-known member
Joined
Jun 30, 2003
Messages
54
Gentlemen:

Could you please let me know the right code for extracting the 20 top most and 20 least profitable customers using the SALES column in Database1 into listbox1 and 2?

On listbox1 I need to show:
20 MOST PROFITABLE CUSTOMERS
TotalAmount / CustomerName / CustomerCity

On listbox2 I need to show:
20 LEAST PROFITABLE CUSTOMERS
TotalAmount / CustomerName / CustomerCity


Thanks

Andy

I
 
Isnt there something like

"SELECT TOP 20 * FROM <table> ORDER BY SALES ASC"
"SELECT TOP 20 * FROM <table> ORDER BY SALES DESC"


(that is SQL for MS SQL Server. COuld be "FIRST 20" in Access
 
If not FIRST 20,

Why dont you sort the table using the "total amount" and extract the the first 20 from the table for top and leat 20 from table.
 
Back
Top