title: SQL sum rows in union
body: <p>I'm trying to SUM two rows obtained from differente SQL queries in UNION, is this possible?
  All I can achieve is the two separate rows but I can't SUM them, DB engine keeps me telling that there's an error in the syntax near the *) FROM (the part next to the SUM)...</p>
  
  <p>Here's the query:</p>
  
  <pre><code>SELECT * FROM
  
  (SELECT COUNT(*) as cntclients                                                                                               
     FROM                                                                                                                      
     (SELECT DISTINCT clientkey AS clients                                                                                     
        FROM &lt;table&gt;
       WHERE &lt;conditions...&gt;)                                                                                                                 
     ) AS clients                                                                                                              
  ) cntclients
  
  UNION
  
  (SELECT SUM(occurrences) AS cntclientsad                                                    
     FROM &lt;table2&gt;
     WHERE &lt;conditions...&gt;                                     
  )
  </code></pre>
  
  <p>This throws me for example:</p>
  
  <pre><code>cntclients
  ----------
  901
  50
  </code></pre>
  
  <p>Adding a SELECT SUM(*) FROM instead of the SELECT * FROM in the first line, and surrounding the two queries with parentheses just throws me the mentioned error...</p>
  
  <p>I would like</p>
  
  <pre><code>cntclients &lt;- or whatever name...
  ----------
  951
  </code></pre>
  
  <p>Any ideas how this sum should work?</p>