title: SQL Server 2008 Running Total
body: <p>I'm aware this has been asked but I'm completely baffled.</p>
  
  <p>Trying to run a running total by day using SQL Server 2008. Have looked at solutions elsewhere but would am still completely perplexed.</p>
  
  <p>The below code shows Daily sales but I cannot make a running total fit. Have looked at the similar solutions here but no luck. Have looked at partition by, order by, CTE etc but I'm just not there yet with SQL.</p>
  
  <p>Would appreciate help, my code is below. I know this only returns the total grouped by day...</p>
  
  <pre><code>SELECT
      dim_invoice_date.invoice_date AS 'Invoice Date',
      round(SUM(invoice_amount_corp),2) AS 'Sales'
  FROM 
      fact_om_bud_invoice 
  JOIN
      dim_invoice_date ON fact_om_bud_invoice.dim_invoice_date_key = dim_invoice_date.dim_invoice_date_key 
  WHERE   
      dim_invoice_date.current_cal_month IN ('Current') 
      AND fact_om_bud_invoice.budget_code IN ('BUDGET') 
  GROUP BY 
      dim_invoice_date.invoice_date
  HAVING 
      ROUND(SUM(invoice_amount_corp), 2) &lt;&gt; 0
  ORDER BY
      'Invoice Date'
  </code></pre>
  
  <p>This returns the output:</p>
  
  <pre><code>Invoice Date     Sales 
  -----------------------
  4/10/2016       24,132 
  5/10/2016       15,849 
  6/10/2016       24,481 
  7/10/2016       10,243 
  10/10/2016      42,398 
  11/10/2016      24,187 
  </code></pre>
  
  <p>Required format is something like:</p>
  
  <pre><code>Invoice Date     Sales   Running Sales
  -------------------------------------------
  04/10/2016      24,132   24,132
  05/10/2016      15,849   39,981 
  06/10/2016      24,481   64,462
  07/10/2016      10,243   74,705
  10/10/2016      42,398   117,103
  11/10/2016      24,187   141,290
  </code></pre>
  
  <p><i>dim_invoice_date</i> is a numeric field, it's looking up a separate date table to display as date time.</p>