Sample table ID: (num
is a key so there wouldn't be any duplicates)
num
1
5
6
8
2
3
I need a query to make this: Desired output: (Should be sorted and have a cumulative sum column)
num cumulative
1 1
2 3
3 6
5 11
6 17
8 25
In Mysql I have
Select num as n,
(select sum(num) from ID where num <= n)
from ID order by n;
I picked up this example in this link but in MySqlServer