|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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. |
|
#2
|
|||
|
|||
|
Code:
select customerName,sum(totalSales) as total from orders group by customerName change names as apropriate. |
|
#3
|
|||
|
|||
|
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. |
![]() |
| Viewing: Dev Shed Forums > Databases > Oracle Development > Help with query to output totals... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|