How would you do to transform a Column in a table from this:
ColumnA ColumnB
2 a
3 b
4 c
5 d
1 a
to this:
ColumnA ColumnB
3 a
6(=3+3) b
10(=4+3+3) c
15(=5+4+3+3) d
I'm interested to see esp. what method you would pick.
Like this:
This should give you:
Here is a live demo
Not sure if this is optimal, but how about (SQL Fiddle):
Try the below script,
I'd generally avoid trying to do so, but the following matches what you've asked for:
Result:
For small data sets, this will be fine. But for larger data sets, note that the last row of the table relies on obtaining the
SUM
over the entire contents of the original table.