Customer
CustomerID Name
4001 John Bob
4002 Joey Markle
4003 Johny Brown
4004 Jessie Black
Orders
OrderID Customer Status
50001 4001 Paid
50002 4002 Paid
50003 4001 Paid
50004 4003 Paid
50005 4001 Paid
50006 4003 Paid
50007 4004 Unpaid
I tried this join
Select c.Customer, COUNT(o.OrderID) as TotalOrders
from Customer c
inner join Orders o
on c.Customer = o.Customer
Where o.Status = 'Paid'
Group by c.Customer
But here is the result.
Customer TotalOrders
4001 3
4002 1
4003 2
The customer with unpaid is not included. How I will include all the customer ?
Customer TotalOrders
4001 3
4002 1
4003 2
4004 0