I'm trying to create a running total based on groups of records. My data looks like the below
Country | Genre | Month | Amt
A X 1 5
A X 2 3
B X 1 8
B Y 1 10
A X 1 12
I'd like to do a running sum on Amt grouped by unique occurences of Genre and Month for each Country. So my desired output is
Country | Genre | Month | Amt | RunAmt
A X 1 5 5
A X 2 3 3
B X 1 8 8
B Y 1 10 10
A X 1 12 17
Since Genre = X and Month = 1 has occurred previously for country A.
My attempt has been sum(amt) over (partition by country, genre, month order by month rows between unbounded preceding and current row)
but it seems to do a running sum over every row not for unique occurences by country. Any help would be appreciated.