Reputation: 11
Cumulative sum and partitioned sum from same expression contour ? Can we achieve this ?
Tried to write this :
SUM("mass") OVER (PARTITION BY "class" ORDER BY "year" ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS "cumulative_sum", SUM("mass") OVER (PARTITION BY "class" ORDER BY "year" ASC ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING) AS "partition_sum"
Two new columns one with cumulative sum and another with partitioned sum
Upvotes: 0
Views: 307