Systems, consultation and development 

Facebook E-mail

Cumulative totals with CTE

Following on from this post, here is an alternative that uses a lot less grunt. (Using the same testtable) ;with cte (i,v,running_total) as { select i,v,v from testtable where i = 1 // initialise the first entry union all select x.i, x.v, cte.running_total + x.v from cte join testtable x on cte.i+1 = x.i }…

Home Posts tagged "cte"