How do I count without adding duplicates?

D

Dazed

Hello, you guys have been a gem for me, so I will give it another go. I
need to figure out how many customers there are in a given zip/postal
code area based on invoices. The problem is that if I count them, one
customer may have bought two items and will therefore come up twice.
how do I change it so that it will only count the same "sold to
customer #", once? Here are the fields and the SQL if you could keep it
clean, ( and easy language as possible) I would appreciate it very
much.
FSA(postal codes) SubTotal Subtotals Sold to Customer#

SELECT Left([customer table].[Zip/Postal Code],3) AS FSA, Sum([order
table].SubTotal) AS [Total Sales], Avg([order table].SubTotal) AS
[Average Sale], Count([order table].[Sold to Customer]) AS [CountOfSold
to Customer]
FROM [customer table] INNER JOIN [order table] ON [customer
table].[Cust#] = [order table].[Sold to Customer]
GROUP BY Left([customer table].[Zip/Postal Code],3);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top