title: SQL Show 0 Values when no values between date range
body: <p>i have some problems with my sql query. 
  Im selecting some values with a specific date range.
  for example 2018-05-01 to 2018-05-13 this is the output.</p>
  
  <pre><code>SUM  CalendarWeek
  8    18
  5    19
  </code></pre>
  
  <p>If the user will select now a date between 2018-04-01 and 2018-05-13 i want to show a 0 instead when there are no values. </p>
  
  <p>For example:</p>
  
  <pre><code>SUM  CalendarWeek
  0    13
  0    14
  0    15
  0    16
  0    17
  8    18
  5    19
  </code></pre>
  
  <p>My Query:</p>
  
  <pre><code>SELECT SUM(Codes) AS 'Sum', CW FROM(
  SELECT Count(*) AS 'Codes', DATEPART(wk, ScanDate) AS 'CW',
  FROM [Table]
  WHERE CONVERT(date, ScanDate, 102) &gt;= '2018-01-01' AND CONVERT(date, ScanDate, 102) &lt;= '2018-05-13' 
  GROUP BY ScanDate,  DATEPART(wk, ScanDate) 
  UNION ALL 
  SELECT Count(*) AS 'Codes', DATEPART(wk, ScanDate) AS 'CW', ScanDate
  FROM [Table_Archive] 
  WHERE CONVERT(date, ScanDate, 102) &gt;= '2018-01-01' AND CONVERT(date, ScanDate, 102) &lt;= '2018-05-13'
  GROUP BY ScanDate, DATEPART(wk, ScanDate)) test 
  GROUP BY CW, ScanDate
  ORDER BY CW ASC
  </code></pre>
  
  <p>any ideas how to solve this? 
  Thanks</p>