Cumulative Totals


There is nothing spectacular about this tip, more that I've seen a lot of postings of late asking for how to have cumulative totals in SQL. So here is a generic example of performing a "running" total using the new analytic facilities available from 8.1.6 and above.


select ( sum(COLUMN_TO_SUM) over ( order by COLUMN_TO_SUM range unbounded preceding ) )
from MY_TABLE