Hello,
I am trying to build a query to give me the number of customers that have bought an item.
Here is what my table looks like
Customer Name
Item Number
Qty
Dollars
so I have customer XYZ that has bought item number 001 different times with different quantities over the past 5 years.
I would like to see
Customer Name Item Number Qty Dollars Num Of Cust
XYZ 001 25365 $5689 1
But instead I get this
Customer Name Item Number Qty Dollars Num Of Cust
XYZ 001 25365 $5689 45
45 is the number of times that customer XYZ has bought the item
Here is the SQL statement that I am using
I am trying to build a query to give me the number of customers that have bought an item.
Here is what my table looks like
Customer Name
Item Number
Qty
Dollars
so I have customer XYZ that has bought item number 001 different times with different quantities over the past 5 years.
I would like to see
Customer Name Item Number Qty Dollars Num Of Cust
XYZ 001 25365 $5689 1
But instead I get this
Customer Name Item Number Qty Dollars Num Of Cust
XYZ 001 25365 $5689 45
45 is the number of times that customer XYZ has bought the item
Here is the SQL statement that I am using
Code:
SELECT Customer, item, Sum(qty) AS SumOfqty, Sum(dollars) AS SumOfdollars, Count(customer) AS num_of_customers
FROM mylib
GROUP BY customer, item
HAVING (((item)="001"));