title: SQL COUNT() Returning 0 When Dividing
body: <p>I am trying to create a really quick &amp; simple report for a client.  I am sure I have some syntax wrong since the result of the % is always 0.  Here is the SQL and the sample result set:</p>
  
  <pre><code>DECLARE @TotalCount INT
  SELECT @TotalCount = (SELECT COUNT(1) FROM TABLE WHERE OrderCompleteFlag = 1)
  PRINT @TotalCount
  
  SELECT '21 - 25', COUNT(1) AS 'COUNT', (COUNT(1) / @TotalCount) FROM TABLE WHERE DATEDIFF(yy, DateOfBirth, GETDATE()) BETWEEN 21 and 35 AND OrderCompleteFlag = 1
  UNION
  SELECT '26 - 30', COUNT(1) AS 'COUNT', (COUNT(1) / @TotalCount) FROM TABLE WHERE DATEDIFF(yy, DateOfBirth, GETDATE()) BETWEEN 26 and 30 AND OrderCompleteFlag = 1
  </code></pre>
  
  <p>Results:</p>
  
  <pre><code>11175
  
  21 - 25 7631    0
  26 - 30 3544    0
  </code></pre>
  
  <p>Any help would be greatly appreciated. thx!</p>
  
  <p>Dennis</p>
  
  <pre><code>*** UPDATE ***
  
  The quick fix (on SQL SERVER) was to just declare @TotalCount as 
  DECIMAL or NUMERIC.  thanks to everyone that helped solve with input! :)
  </code></pre>