title: SUM two SELECT COUNT Queries with GROUP BY
body: <p>I have two queries in a linked database (linking tables from two different project databases). I need to combine the queries to get a total count that is grouped by Interaction_Type1. The SQL code is as follows:</p>
  
  <p>Query#1:</p>
  
  <pre><code>SELECT Sum(Temp.cnt) AS SumOfcnt, Temp.Interaction_Type1
  FROM (SELECT COUNT(*) as cnt, Interaction_Type1 from AMERILOCKMasterConversionTable 
  GROUP BY Interaction_Type1
  
  UNION ALL
  
  SELECT COUNT(*), Interaction_Type2 from AMERILOCKMasterConversionTable
  GROUP BY Interaction_Type2
  
  UNION ALL
  
  SELECT COUNT(*), Interaction_Type3 from AMERILOCKMasterConversionTable
  GROUP BY Interaction_Type3
  )  AS Temp
  GROUP BY Temp.Interaction_Type1;
  </code></pre>
  
  <p>and Query#2</p>
  
  <pre><code>SELECT Sum(Temp.cnt) AS SumOfcnt, Temp.Interaction_Type1
  FROM (SELECT COUNT(*) as cnt, Interaction_Type1 from MARKETMasterConversionTable 
  GROUP BY Interaction_Type1
  
  UNION ALL
  
  SELECT COUNT(*), Interaction_Type2 from MARKETMasterConversionTable 
  GROUP BY Interaction_Type2
  
  UNION ALL
  
  SELECT COUNT(*), Interaction_Type3 from MARKETMasterConversionTable 
  GROUP BY Interaction_Type3
  )  AS Temp
  GROUP BY Temp.Interaction_Type1;
  </code></pre>
  
  <p>I would like the query to yeild the following results:</p>
  
  <pre><code>Interaction_Type1          Total
  Left_Message                23
  Made_Contact                16
  Bad_Phone_Number             8
  No_Answer                   12
  </code></pre>
  
  <p>I am brand new to SQL and have researched all of this online and have had no luck in combining these two queries to produce the desired results.</p>
  
  <p>Any help would be GREATLY appreciated!!</p>
  
  <p>Thanks!
  Red</p>