SunQuest
           Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

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 May 20th, 2004, 10:40 AM
Smakit Smakit is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 19 Smakit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Help with query to output totals...

Let me explain what I am trying to do and what I have -- figure that will help There are a few tables, one with customers and information, one with customer orders and what / when / how many they bought, and a final one that shows items and prices.

So, now what I want to display is a report for sales total by customer - so I want to show, say:

Name Total Sales
----- -----------
Smith $250.00
Rath $800.00


The thing is, each customer will have multiple orders, so the way I have it going now it will show their name a lot, with totals only for that particular order (through an aggregate function). So it looks like this...

Name Total Sales
----- -----------
Smith $50.00
Smith $50.00
Smith $200.00
Rath $600.00
Rath $200.00

And that isn't at all how I want it! The thing is, Im not sure what really to do to make it like that.

Any basic code ideas? If you need more info, just let me know.

Reply With Quote
  #2  
Old May 20th, 2004, 11:13 AM
swampBoogie swampBoogie is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jan 2003
Location: Paris Uppland
Posts: 1,766 swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Weeks 4 Days 6 h 24 m 8 sec
Reputation Power: 37
Code:
select customerName,sum(totalSales) as total
from orders
group by customerName


change names as apropriate.

Reply With Quote
  #3  
Old May 20th, 2004, 02:08 PM
Smakit Smakit is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 19 Smakit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Red face Hmm

Would I do that even if the totalSales is a multiplication value? IOW, total sales is actually quantity*price (not held in a column, just done on the fly).

So would it just be...

Code:
select customerName,sum(quantity*price) as total
from orders
group by customerName


I can't be 100% sure, but I thought that is what I tried, and it still reports it with multiple names listed (of the same name that is, like in the example).

Ill check it out again, though. Thx.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Help with query to output totals...


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 3 hosted by Hostway