Skip to content
Advertisement

Convert a running total oracle sql query to a final total

I have the following query that works and gets me the total that I need.

However, i need to change it so that it just displays the final total instead of every transaction leading up to the total. I have tried converting it by group by rollup, group by group sets, using max transaction number, but my total never matches and I don’t fully understand the SUM decode part of select statement. I believe i need to move part of that to the where statement to do what i need.

Here is the query:

Any help on how to convert this so i just get the grand total that matches the final running total would be appreciated. My end goal would be to get the grand total for a list of pidms(IDS) one total for each pidm in a row.

Advertisement

Answer

You would seem to want to remove the order by. I’ll also do the favor of converting to standard SQL syntax:

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement