Michael
Michael

Reputation: 3229

How to create a query in MS Access that allows you to sum each customers total cost?

I need to be able to sum each customer's expenses to get a total bill for them. If that bill is less that a certain number (let's say $3000), then it should not be included in my report. How would I go about writing this? The costs are stored in a column called "Rate" and the customers names are stored in the columns "FirstName" and "LastName" and each customer has a CustomerID. I am thinking something along the lines of

(sum of rates Where CustomerID is the same) >= 3000

So for example sum all rates when the CustomerID is 1, 2, 3, etc. That was my attempt at pseudocode as I'm new to Access and don't quite know the syntax yet.

Thanks in advance!

Upvotes: 0

Views: 247

Answers (1)

Y.B.
Y.B.

Reputation: 3586

Select CustomerID, FirstName, LastName, Sum(Rate) As Expenses
From [TableName]
Group By CustomerID, FirstName, LastName
Having Sum(Rate) >= 3000

Upvotes: 1

Related Questions