Don't forget that if order matters, you probably can still use windowing functions and have no problem - I wrote an iterative but still set based newtons method of least squares in CTEs/windowing functions and it was tens of thousands of times faster than a looping option.