Sample table ID: (num is a key so there wouldn\'t be any duplicates)
num 1 5 6 8 2 3
Desired output: (Should be sorted and have a cumul
Since MySQL 8, cumulative sums are ideally calculated using window functions. In your case, run:
SELECT num, SUM(num) OVER (ORDER BY num) cumulative FROM id