title: CAST is not working in SQL query
body: <p>I use the StackExchange Data Explorer to calculate the average number of answers for Java questions that are not closed and have an accepted answer:</p>
  
  <pre><code>DECLARE @tagId int;
  
  SELECT  @tagId = Id
  FROM    Tags         
  WHERE   TagName = 'java';
  
  SELECT  CAST(AVG(AnswerCount) as DECIMAL(5,2)) 
  FROM    posts p 
  JOIN    PostTags pt ON pt.PostId = p.Id
  WHERE   pt.TagId = @tagId
      AND     p.PostTypeID = 1
      AND     p.AcceptedAnswerID IS NOT NULL
      AND     p.ClosedDate IS NULL;
  </code></pre>
  
  <p>However, I always get 2 as a result, even so I try to cast the result to a decimal. I also tried to cast first each result and then cast the average again, but still, I get 2 as a result instead 2.29....</p>
  
  <p>What's my error?</p>