title: how to count two similiar Sql select and add together?
body: <p>I have two query and I want to add their result together.
  Basically i want to count all occurrences then add those ones to it where it has a connection with another table. So if it appears in the other table 2 times the final count value for the notRelevantId should be 3.</p>
  <pre><code>SELECT table1.notRelevantId, COUNT(0) as numberOfOccurrences
  FROM table1
  WHERE Deleted = 0 (AND other filters)
  GROUP BY table1.notRelevantId
  
  SELECT table1.notRelevantId, COUNT(0) as numberOfOccurrences
  FROM table1
  INNER JOIN table2 ON table1.connectionId = table2.connectionId
  WHERE Deleted = 0 (AND other filters) AND table2.connectionId is not null
  GROUP BY table1.notRelevantId
  </code></pre>
  <ol>
  <li>query result</li>
  </ol>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>notRelevantId</th>
  <th>numberOfOccurrences</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>464</td>
  <td>15</td>
  </tr>
  <tr>
  <td>536</td>
  <td>1</td>
  </tr>
  <tr>
  <td>528</td>
  <td>358</td>
  </tr>
  <tr>
  <td>465</td>
  <td>254</td>
  </tr>
  </tbody>
  </table>
  </div>
  <ol start="2">
  <li>query result</li>
  </ol>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>notRelevantId</th>
  <th>numberOfOccurrences</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>464</td>
  <td>14</td>
  </tr>
  <tr>
  <td>528</td>
  <td>352</td>
  </tr>
  <tr>
  <td>465</td>
  <td>166</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Expected result:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>notRelevantId</th>
  <th>numberOfOccurrences</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>464</td>
  <td>29</td>
  </tr>
  <tr>
  <td>536</td>
  <td>1</td>
  </tr>
  <tr>
  <td>528</td>
  <td>710</td>
  </tr>
  <tr>
  <td>465</td>
  <td>420</td>
  </tr>
  </tbody>
  </table>
  </div>