title: sql server - get count and column value from two tables for a report
body: <p>I need to select the counts from two tables that share a common column which is the <code>clientId</code> and group the totals by the <code>clientIds</code> for a given day and the <code>dateadded</code> column in both tables is in the datetime format.</p>
  
  <p>For example the result should show:</p>
  
  <pre><code>ClientId     Total1 Total2  
  aaaa           1      2
  bbbbb          43     45
  ccccc          123    355
  </code></pre>
  
  <p>etc. for 2011-03-25</p>
  
  <p>what I currently have is </p>
  
  <pre><code>select 
     (select clientid,count(*) as total1 from TFeed where dateadded = getdate() 
      group by clientId),
     (select clientId, count(*) as total2 from WFeed where dateadded = getdate() 
      group by clientid)
  </code></pre>
  
  <p>This is of course wrong.
  ERROR: only one expression can be specified in the select list when the subquery is not introduced with EXISTS. Also for consideration, these are very large tables - over 3 million records and growing. Any help appreciated</p>
  
  <p>EDIT:</p>
  
  <p>about the time - if dateadded = '2011-03-25 12:00:34 0011', how can I compare the time to 
  get dateadded = @getdate() and select all the records for today.</p>
  
  <p>while my query is still running - off topic question...since this is a reporting query and I want to run it regularly to update totals  so that when client opens web page or clicks on report it would deliver totals without having to run the query and just select the last totals from  a database. do I then need to a have a different query or run this every hour or so.</p>