pietlinden (9/26/2016)
If the reason for your loop is to implement a running total, why not just use a Window function and do something likeSUM( <column to be summed> ) OVER PARTITION BY (<grouping column(s)> ORDER BY <column>)
Could you post some representative data and some output so we could test it out?
Thanks!
Pieter
If you use this approach, you should specify the window frame (generally ROWS UNBOUNDED PRECEDING), because the default is RANGE UNBOUNDED PRECEDING, and which is much slower than specifying the range using the ROWS keyword.
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA