Hi,
I am trying to make a report which will show products bought by customers.
I have Products
, TransDetails
, TransHeaders
, Customers
tables and i have to pick all products and for each product i have to show sales for each customer. if customer has not bought any particular product it should still be visible on report with 0 sales. user should be able to run this report for a particular customer or group of customers.
The Problem i am facing right now is, if i include customers table in my sql query then it only shows products bought by customer and it doesnt show products which customer has not bought.
SELECT Products.SalesCategory, Products.ProductCode, Products.ProductTitle, Customers.CustomerCode, Transdetails.quantity
From Products left outer join Transdetails on Products.ProductID= Transdetails.ProductID
Left Outer Join Customers on Customers.CustomerId= Transdetails.CustomerID
Where SalesCategory like 'XYZ' and Products.Status like 'A'
and customers.customercode like 'BEST'
order by SalesCategory, ProductCode, ProductTitle