• Erland Sommarskog (9/2/2013)


    I assume that you mean set-based iteration. That is by no means an atypical method, but one a good SQL programmer should master.

    Yes and absolutely agreed. That's why I called it atypical though. 😉

    Of course, for this particular problem, the correct solution is an ordered aggregate. No that is not possible on SQL 2008, but it's reasonable to assume that a class would teach from the most recent version. At least if the features are ANSI-compatible.

    I guess "possible" depends a lot on whether or not you consider the "Quirky Update" to be a form of ordered aggregate or not but I do get your point. As reasonable as it sounds, though, I would't assume that any given class has been updated to the latest version epecially when the OP posted in a 2008 forum.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)