Hello, I'm trying to create a query to count each customer's (tblCustomer) Active or Open contracts (tblContract). I'm using a left join, but it's still not taking all entries from tblCustomer - if the count is zero, it's not showing up as a line in the query. I have 533 customers, but the query only produces 465 records. Here is my SQL statement:
Is there a way to do this without using a DCount?
Code:
SELECT tblCustomer.CustomerID, tblCustomer.CoName, Count(tblContract.ContractID) AS [Open Active Count]
FROM tblCustomer LEFT JOIN tblContract ON tblCustomer.CustomerID = tblContract.CustomerID
WHERE tblContract.Status = "Active" Or tblContract.Status = "Open"
GROUP BY tblCustomer.CustomerID, tblCustomer.CoName