title: Return All Months & Years Between Date Range - SQL
body: <p>I'm a bit stumped how I might go about this.</p>
  
  <p>I have a very basic query, that currently returns sales for each product, by year and month.
  It is grouping by year/month, and summing up the quantity. 
  This returns one row for each product/year/month combo where there was a sale.</p>
  
  <p>If there was no sale for a month, then there is no data.</p>
  
  <p>I'd like my query to return one row of data for each product for each year/month in my date range, regardless of whether there was actually an order.</p>
  
  <p>If there was no order, then I can return 0 for that product/year/month.</p>
  
  <p>Below is my example query.</p>
  
  <pre><code>Declare @DateFrom datetime, @DateTo Datetime
  Set @DateFrom = '2012-01-01'
  set @DateTo = '2013-12-31'
  
  select 
  Convert(CHAR(4),order_header.oh_datetime,120) + '/' + Convert(CHAR(2),order_header.oh_datetime,110) As YearMonth,
  variant_detail.vad_variant_code,
  sum(order_line_item.oli_qty_required) as 'TotalQty'
  
  From 
  variant_Detail
  join order_line_item on order_line_item.oli_vad_id = variant_detail.vad_id
  join order_header on order_header.oh_id = order_line_item.oli_oh_id
  
  Where 
  (order_header.oh_datetime between @DateFrom and @DateTo)
  
  Group By 
  Convert(CHAR(4),order_header.oh_datetime,120) + '/' + Convert(CHAR(2),order_header.oh_datetime,110),
  variant_detail.vad_variant_code
  </code></pre>