Skip to Main Content


Oracle APEX cumulative sum / running total over month and year

hiddenonearthJun 26 2022

I am trying to implement an interactive report based on refreshing dynamics actions where a user can check the current visits per month and year for different accounts. He can select the data via a popup lov for the months and the year.
I'd like to implement a column where the running total is displayed by months for every account
For instance the number of visits for account01:
January: 150
February: 200
March: 50
What I want to achieve is a running total by month and year filtered
January: 150
February: 350 (Jan + Feb)
March: 400 (Jan + Feb + Mar)
I tried this with the following SQL Query where I managed to get the total for every month and for every individual account but the cumulative sum for the next months is not working.
The data gets refreshed after another month is selected via the Popup LoV

    sum(count(*)) OVER (PARTITION BY user_account, to_char(year, 'YYYY'), to_char(month, 'MM') ORDER BY to_char(year, 'YYYY'), to_char(month, 'MM'),user_account)
     as sum_total
    to_char(ord.year, 'YYYY'),
    to_char(ord.month, 'MM')

Any idea on how I can display the cumulative sum by the months.
Appreciate your help.
Thank you.

Post Details
Added on Jun 26 2022