Summing totals in a query (2 Viewers)

raydan

Registered User.
Local time
Today, 02:10
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
 

raydan

Registered User.
Local time
Today, 02:10
Joined
Aug 24, 2005
Messages
28
Well, just found the totals button. So I actually helped myself. :p
 

raydan

Registered User.
Local time
Today, 02:10
Joined
Aug 24, 2005
Messages
28
Actually its still not totaling the amounts. Now im lost.
 

SMatthews

Registered User.
Local time
Today, 03:10
Joined
Nov 13, 2001
Messages
38
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;
 

raydan

Registered User.
Local time
Today, 02:10
Joined
Aug 24, 2005
Messages
28
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?
 

raydan

Registered User.
Local time
Today, 02:10
Joined
Aug 24, 2005
Messages
28
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

Top Bottom