I have 3 tables, Stock,Sales and Customers
The Stock file links to the Sales by StockCode, the Sales Links to the Customers by CustCode
The Stock file has a field that on specified products has Points allocated to it.
I need to produce a report where each customer has all of the Stock items that has points allocated to it listed regardless of whether there have been any sales or not. Eg:
Customer1 StockItem1 Salesqty=1
Customer1 StockItem2 Salesqty=0
Customer1 Stockitem3 Salesqty=2
Customer2 StockItem1 Salesqty=0
Customer2 StockItem2 Salesqty=0
etc.
I cant get my query to produce this.
Here is what I have so far.
SELECT
customer.`title`,
stock.`stockcode`,
stock.`title`,
stock.`zpoints`,
sales.`qtyinv`
FROM
`stock` stock LEFT OUTER JOIN `sales` sales ON stock.`stockcode` = sales.`stockcode`,
`customer` customer
WHERE
sales.`custcode` = customer.`custcode` AND
inventry.`zpoints` > 0.00
ORDER BY
customer.`title` ASC
Please can someone help me with this. Thanks
The Stock file links to the Sales by StockCode, the Sales Links to the Customers by CustCode
The Stock file has a field that on specified products has Points allocated to it.
I need to produce a report where each customer has all of the Stock items that has points allocated to it listed regardless of whether there have been any sales or not. Eg:
Customer1 StockItem1 Salesqty=1
Customer1 StockItem2 Salesqty=0
Customer1 Stockitem3 Salesqty=2
Customer2 StockItem1 Salesqty=0
Customer2 StockItem2 Salesqty=0
etc.
I cant get my query to produce this.
Here is what I have so far.
SELECT
customer.`title`,
stock.`stockcode`,
stock.`title`,
stock.`zpoints`,
sales.`qtyinv`
FROM
`stock` stock LEFT OUTER JOIN `sales` sales ON stock.`stockcode` = sales.`stockcode`,
`customer` customer
WHERE
sales.`custcode` = customer.`custcode` AND
inventry.`zpoints` > 0.00
ORDER BY
customer.`title` ASC
Please can someone help me with this. Thanks