title: Combining tables with same columns in SQL Server
body: <p>I am trying to combine two tables with same columns in SQL Server. </p>
  
  <p>Individually, my queries work fine:</p>
  
  <pre><code>Select 
      _NAME, COUNT(_NAME) as Occurrences
  From 
      SP6815_NOK
  Where 
      _VALUE = 1
  Group By 
      _NAME 
  Order By 
      Occurrences desc
  </code></pre>
  
  <p>and</p>
  
  <pre><code>Select 
      _NAME, COUNT(_NAME) as Occurrences
  From 
      SP6814_NOK
  Where 
      _VALUE = 1
  Group By 
      _NAME
  Order By 
      Occurrences desc
  </code></pre>
  
  <p>Resulting in:</p>
  
  <p><a href="http://i.stack.imgur.com/hia91.png" rel="nofollow">Occurrences for SP6815_NOK</a></p>
  
  <p>and</p>
  
  <p><a href="http://i.stack.imgur.com/n0SsM.png" rel="nofollow">Occurrences for SP6814_NOK</a></p>
  
  <p>I need the query to perform the exact filters as listed in my individual queries but every time I try a 'join' clause or simply listing both tables under the 'from' statement, I get an ambiguous column error.  </p>
  
  <p>I think it might be because some of the messages or "_NAMES" are shared by both tables, but I still need it to count up the occurrences and not overwrite them. Could anyone help?</p>