Oracle SQL Analytic query - recursive spreadsheet-like running total
I have the following data, composed of the A value, ordered by MM (month). The B column is computed as GREATEST(current value of A + previous value of B, 0) in a spreadsheet-like fashion. How can I compute B using a SQL Query? I tried using Analytic Functions, but I was unable to succeed. I know there is the Model Clause ; I found a similar example , but I don't know where to begin. I am using Oracle 10g, therefore I cannot use recursive queries. Here is my test data: MM | A | B -----------+--------+------ 2012-01-01 | 800 | 800 2012-02-01 | 1900 | 2700 2012-03-01 | 1750 | 4450 2012-04-01 |