title: SQL query help, ms sql server 2005 (group by and having)
body: <p>I writing a query within ms sql server 2005 and having some trouble getting it to run. I need my query to include: </p>
  
  <ol>
  <li>Include all docs from Date Range 2009-07-20 to 2009-08-04</li>
  <li>Include a Sum column using the 'Size' field</li>
  <li>Include a record count column</li>
  <li>Group By Name</li>
  </ol>
  
  <p></p>
  
  <pre><code>select Name, count(*) AS FileCount, SUM(Size)  
  From alldocs 
  Group by DirName 
  HAVING TimeCreated &gt;= '2009-07-20' AND 
  TimeCreated &lt;= '2009-08-04'
  </code></pre>