Query Parameters (1 Viewer)

GreenshootProgrammer

Registered User.
Local time
Today, 02:57
Joined
Jan 16, 2013
Messages
74
I have an invoice query that has a lot of fields, I want to create a copy of the query that searches for the best paying customer. How would I add up all the costs per customer and find out which one is the most?
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 18:57
Joined
Aug 30, 2003
Messages
36,127
You want a totals query along the lines of:

SELECT Customer, Sum(Amount)
FROM TableName
GROUP BY Customer
ORDER BY Sum(Amount) DESC
 

GreenshootProgrammer

Registered User.
Local time
Today, 02:57
Joined
Jan 16, 2013
Messages
74
You want a totals query along the lines of:

SELECT Customer, Sum(Amount)
FROM TableName
GROUP BY Customer
ORDER BY Sum(Amount) DESC

I know about totals in queries but I'm a bit confused about your instructions.
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 18:57
Joined
Aug 30, 2003
Messages
36,127
If you know about them, create one with those 2 fields, grouping on the customer and summing the amount, and put a sort on the amount field.
 

Users who are viewing this thread

Top Bottom