1
To do this, use the OVER
about the function SUM
. The OVER will make the SUM apply under one condition, in which case it will be all numbers up to the current "offset".
SELECT preço, SUM(preço) OVER (ORDER BY preço) AS "SOMA CONSECUTIVA" FROM valores;
See working on SQL Fiddle.
you want to add a column with sum to an existing table, or you want to create a table with a column that repeats the first record, if there is no and sum with previous if already exists?
– Paulo Ricardo