Hi I need to write a query that will show a list of retailers and a count of all of there orders.
I came up with this;
SELECT Retailers.NA_ID, Count(Orders.NA_ID) As countOfOrders
FROM Retailers
Left Outer Join
Orders
ON Retailers.NA_ID = Orders.NA_ID
WHERE (Orders.JointOR_ID <> '' OR Orders.OT_ID=2)
Group By
Retailers.NA_ID
Now the problem here is it shows all the retailers that have had at least one order but I want it to every retailer and a 0 Where they have had no orders.
Any help would be greatly appreciated.
I came up with this;
SELECT Retailers.NA_ID, Count(Orders.NA_ID) As countOfOrders
FROM Retailers
Left Outer Join
Orders
ON Retailers.NA_ID = Orders.NA_ID
WHERE (Orders.JointOR_ID <> '' OR Orders.OT_ID=2)
Group By
Retailers.NA_ID
Now the problem here is it shows all the retailers that have had at least one order but I want it to every retailer and a 0 Where they have had no orders.
Any help would be greatly appreciated.