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
You can use a temporary variable to calculate the cumulative sum:
SELECT a.num, (@s := @s + a.num) AS cumulative FROM ID a, (SELECT @s := 0) dm ORDER BY a.num;