Oracle Running Total Query
This is an example query to to get cummulative or running totals of financial related data such as sales, payments, tax etc. using the Oracle SUM(..) OVER(ORDER BY ...) syntax. Below is a simple running total of consecutive numbers up to 10. Next example shows the use of this syntax in a typical data warehouse fact table.

Running Total Query
SELECT
 q_tab.ref_no,
 SUM(q_tab.val)
   OVER(ORDER BY q_tab.ref_no) totals
FROM 
 (SELECT  level ref_no,  level val
  FROM  DUAL
  CONNECT BY level <=10
 ) q_tab;


Next example

Oracle registered trademark of Oracle Corporation.

Last Revised On: November 08, 2013

  74048