title: Average for each row in MYSQL
body: <p>I would like to ask you guys how to count the average to the results below:</p>
  
  <p>My code looks as follow:</p>
  
  <pre><code>SELECT `milestone_id`, `status`, sum(value), 
      CASE WHEN (status !='done') THEN (value ='0') ELSE sum(value) END as val 
  FROM project_has_tasks 
  WHERE project_id='56' 
  AND milestone_id !=0 
  GROUP BY milestone_id ASC
  </code></pre>
  
  <p>Results:</p>
  
  <pre><code>milestone_id | status | sum(value) | val |
  121            done     81           81
  122            undone   25           0
  123            done     64           64
  124            done     23           23
  </code></pre>
  
  <p>What I wanna to do is to put there an average number (as avg) for each row so the results should looks like this:</p>
  
  <pre><code>milestone_id | status | sum(value) | val | avg |
  121            done     81           81    81
  122            undone   25           0     40,5
  123            done     64           64    48,3
  124            done     23           23    42
  </code></pre>
  
  <p>And so on
  The question - How to achieve the results like above?</p>
  
  <pre><code>PS:
  The average for row 121 is from 81/1 = 81
  The average for row 122 is from (81+0)/2 = 40,5
  The average for row 123 is from (81+0+64)/3 = 48,3
  The average for row 124 is from (81+0+64+23)/4 = 42
  </code></pre>