List:General Discussion« Previous MessageNext Message »
From:ISC Edwin Cruz Date:November 11 2005 3:49pm
Subject:RE: Sum entire group listing
View as plain text  
SELECT products.product, products.price, count( log.product ) AS 'Count',
ROUND(price*count(log.product), 2) AS 'Total' FROM products LEFT JOIN log ON
products.product= log.product GROUP BY product  
Union
SELECT 'Total', '', count( log.product ) AS 'Count',
ROUND(price*count(log.product), 2) AS 'Total' FROM products LEFT JOIN log ON
products.product= log.product 


????

-----Mensaje original-----
De: Noel Stratton [mailto:nstratton@stripped] 
Enviado el: Jueves, 10 de Noviembre de 2005 04:36 p.m.
Para: mysql@stripped
Asunto: Sum entire group listing


I am running this query below:
SELECT products.product, products.price, count( log.product ) AS 'Count',
ROUND(price*count(log.product), 2) AS 'Total' FROM products LEFT JOIN log ON
products.product= log.product GROUP BY product  
 
The query above submits this results:
product 	price 	Total Sold 	Total Amount Owed 	
ATM Card	 3.00	 2	 6.00	
Audio Response	 3.00	 0	 0.00	
Check Card	 5.00	 1	 5.00	
Courtesy Pay	 5.00	 2	 10.00	
Draft with Direct Deposit	 5.00	 0	 0.00	
Draft without Direct Deposit	 3.00	 0	 0.00	
E-statement	 5.00	 2	 10.00	
Gap	 20.00	 0	 0.00	
MBI	 10.00	 0	 0.00	
Membersonline	 5.00	 0	 0.00	
New Account	 5.00	 1	 5.00	
New Loan	 5.00	 0	 0.00	
New Mem"Bear" Account	 5.00	 0	 0.00	
 
The results above is exactly what I want.  However, I would like to add one
more thing that I can not figure out.  I would like to sum all calculations
created out of the "Total Amount Owed" field that was created. The answer
should be 36.00.  Any suggestions on how to accomplish this?

Thank You,

 

Thank You,

Noel Stratton
Computer Specialist
Members 1st Credit Union 

 


Thread
Sum entire group listingNoel Stratton10 Nov
Re: Sum entire group listingJigal van Hemert11 Nov
RE: Sum entire group listingISC Edwin Cruz11 Nov