Summing totals in a query

raydan

Registered User.
Local time
Today, 11:57
Joined
Aug 24, 2005
Messages
28
SELECT Commissions.TransactionID, Commissions.OriginatorID, Commissions.AmountPaid, Commissions.DatePaid
FROM Commissions
WHERE ((Commissions.DatePaid)> DateAdd("d", -32, Date()));

I want to add up commissions paid in a month using a simple query and im not sure how to proceed from here. This example will pull records for the last 32 days, but now how do I do the sum commissions.amountpaid to work?

Thanks for any help.

Scott
 
Well, just found the totals button. So I actually helped myself. :p
 
Actually its still not totaling the amounts. Now im lost.
 
Remove DatePaid from the SELECT statement and add GROUP BY for the fields other than AmountPaid.

SELECT Commissions.TransactionID, Commissions.OriginatorID, Sum(Commissions.AmountPaid)
FROM Commissions
WHERE ((Commissions.DatePaid)> DateAdd("d", -32, Date()))
GROUP BY Commissions.TransactionID, Commissions.OriginatorID;
 
TransactionID OriginatorID SumOfAmountPaid
40-0007 101-10005 $78.00
40-0008 101-10003 $600.00
40-0009 101-10001 $500.00
40-0010 101-10001 $2,010.00

This is what im returning when i use:

SELECT Commissions.TransactionID, Commissions.OriginatorID, Sum(Commissions.AmountPaid) AS SumOfAmountPaid
FROM Commissions
WHERE (((Commissions.DatePaid)>DateAdd("d",-32,Date())))
GROUP BY Commissions.TransactionID, Commissions.OriginatorID;


I would like to get one total for each originator. Will I need to separte queries or can this be done in one?
 
SELECT Commissions.OriginatorID, Sum(Commissions.AmountPaid) AS SumOfAmountPaid
FROM Commissions
WHERE (((Commissions.DatePaid)>DateAdd("d",-32,Date())))
GROUP BY Commissions.OriginatorID;

This worked for me. Now I get on total for all originators. Thanks for all the help. The " Sum(Commissions.AmountPaid) AS SumOfAmountPaid " is what saved me. Hope this helps someone out.

Scott
 

Users who are viewing this thread

Back
Top Bottom