Skip to content
Advertisement

Redshift Running SUM challenge

Given the following data sample, I’m trying to perform a running sum() isolated to date, account_no, service. Hoping someone here can help.

I started with this code:

The above worked as expected but then I wanted to see if I could add in other data features such as account_name and service such that I could get specific running costs by snapshot_dt, account_name, or service.

I tried adding these data features in with some grouping statements and ultimately what appeared to happen was a running total based on prior row, I suspect related to rows unbounded preceding.

Advertisement

Answer

Your original code with all the places you need to include account_name and service in between double-stars (**). Take out the double stars and it be fine:

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