title: Create a Query to Combine Data from Two Tables with Similar data
body: <p>In need an aggregate result of two similar tables without getting duplicates. </p>
  
  <p>The tables have similar structure. (date,billed_number,carrier_id,duration...)
  tables are 2019-01-29 and 2019-01-30</p>
  
  <p>I've tried UNION of the same query but I get duplicate entries.</p>
  
  <pre><code> select billed_number, sum(CASE WHEN [account_billed_duration] &gt; 0 THEN 1 END) AS completed
   from alex4..[2019-01-29]
   where billed_number = '702640'
   and carrier_id = 171
   group by billed_number
  
   union all
  
   select billed_number, sum(CASE WHEN [account_billed_duration] &gt; 0 THEN 1 END) AS completed
   from alex4..[2019-01-30]
   where billed_number = '702640'
   and carrier_id = 171
   group by billed_number
  </code></pre>
  
  <p>In this example I'm only using tables  ([2019-01-29] and [2019-01-30])
     I also need to be able to combine more than two tables.  </p>
  
  <p>Result:
  billed_number,completed
  702640  3735
  702640  3539</p>
  
  <p>Expected Result:
  billed_number, completed
  702640  7274</p>