title: Calculate a running total in MySQL
body: <p>I have this MySQL query:</p>
  
  <pre><code>SELECT DAYOFYEAR(`date`)  AS d, COUNT(*) 
  FROM  `orders` 
  WHERE  `hasPaid` &gt; 0
  GROUP  BY d
  ORDER  BY d
  </code></pre>
  
  <p>Which returns something like this:</p>
  
  <pre><code>d  | COUNT(*) |
  20 |  5       |
  21 |  7       |
  22 | 12       |
  23 |  4       |
  </code></pre>
  
  <p>What I'd really like is another column on the end to show the running total:</p>
  
  <pre><code>d  | COUNT(*) | ??? |
  20 |  5       |   5 |
  21 |  7       |  12 |
  22 | 12       |  24 |
  23 |  4       |  28 |
  </code></pre>
  
  <p>Is this possible?</p>