SunQuest
           Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old July 14th, 2003, 08:17 AM
Anibal Hernande Anibal Hernande is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 33 Anibal Hernande User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
How to get the 20 MOST and LEAST profitable customers from an OLEdb into Listboxes 1

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’m using:
VB.NET 2003 Standard
Access 2000

Reply With Quote
  #2  
Old July 14th, 2003, 08:48 AM
karsh44's Avatar
karsh44 karsh44 is offline
Just another guy
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jun 2003
Location: Wisconsin
Posts: 2,915 karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 13 h 6 m 22 sec
Reputation Power: 76
Most profitable-
SELECT Top 20 TotalAmount, CustomerName, CustomerCity FROM Database1 ORDER BY Sales DESC
Might have trouble with negative values, not sure.
For least profitable, change DESC to ASC

To then put these into your list boxes, you need to make a data environment, with 2 commands, which are the 2 queries. Then bind the list boxes to the commands

Reply With Quote
  #3  
Old July 14th, 2003, 09:19 AM
Anibal Hernande Anibal Hernande is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 33 Anibal Hernande User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
karsh44:

Thank you for you reply:

Question:

Do you think this query will add all the values of all the sales corresponding to a specific customer?

What I mean is most customers have many sales, would the query first Sum all sales for each customer and then select the top 20?

Reply With Quote
  #4  
Old July 14th, 2003, 01:56 PM
karsh44's Avatar
karsh44 karsh44 is offline
Just another guy
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jun 2003
Location: Wisconsin
Posts: 2,915 karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 13 h 6 m 22 sec
Reputation Power: 76
No. As the query is now, it will simply sort all the orders in decending and ascending order, no summing included. I don't use Access much, I think there's a wizard or something that might do that automatically.
__________________
--Dave--

U2kgSG9jIExlZ2VyZSBTY2lzLCBOaW1pdW0gRXJ1ZGl0aW9uaXMgSGFiZXM=

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > How to get the 20 MOST and LEAST profitable customers from an OLEdb into Listboxes 1


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway