I have two tables.
An orders table with customer, and date. A date dimension table from a data warehouse.
The orders table does not contain activity for ev
The problem is that you need all customers for all dates. When you do the left outer join, you are getting NULL for the customer field.
The following sets up a driver table by cross joining the customer names and dates:
SELECT driver.customer, driver.fulldate, o.amount
FROM (select d.fulldate, customer
from datetable d cross join
(select customer
from orders
where year(orderdate) in (2012)
) o
where d.calendaryear IN ( 2012 )
) driver LEFT OUTER JOIN
orders o
ON driver.fulldate = o.orderdate and
driver.customer = o.customer;
Note that this version assumes that calendaryear is the same as year(orderdate).