paulwilliams
Registered User.
- Local time
- Today, 05:56
- Joined
- Jul 27, 2012
- Messages
- 10
Hi All
Thanks for taking the time to read my post. This is my problem.
I have a table called SalesData that contains the following fields:
- CustomerName
- ProdCode
- Qty
- Turnover
- SalesDate
This table is simply a list of the products a customer has bought, how many they have bought and how much they spent on those products in any given month.
I have a related table called ProdsToGroups, containing the following fields:
- ProductCode
- ProductGroup
This is a list of all possible product codes and the associated product group for each (there are 2500 product codes and 42 product groups). This table is related to SalesData by [SalesData].[ProdCode] = [ProdsToGroups].[ProdCode].
What I would like to know is how many customers have bought a product from each product group each month and produce a table where each row is the product group, each column is a month and each cell is the unique number of customers who bought a product from that group in that month.
I have used SELECT DISTINCT to produce the list of product groups but I can't then return a number of unique customers who bought from that group. I assume the use of COUNT DISTINCT but i'm having problems putting the query together.
Any help would be greatly appriciated.
Thanks
Paul
Thanks for taking the time to read my post. This is my problem.
I have a table called SalesData that contains the following fields:
- CustomerName
- ProdCode
- Qty
- Turnover
- SalesDate
This table is simply a list of the products a customer has bought, how many they have bought and how much they spent on those products in any given month.
I have a related table called ProdsToGroups, containing the following fields:
- ProductCode
- ProductGroup
This is a list of all possible product codes and the associated product group for each (there are 2500 product codes and 42 product groups). This table is related to SalesData by [SalesData].[ProdCode] = [ProdsToGroups].[ProdCode].
What I would like to know is how many customers have bought a product from each product group each month and produce a table where each row is the product group, each column is a month and each cell is the unique number of customers who bought a product from that group in that month.
I have used SELECT DISTINCT to produce the list of product groups but I can't then return a number of unique customers who bought from that group. I assume the use of COUNT DISTINCT but i'm having problems putting the query together.
Any help would be greatly appriciated.
Thanks
Paul