• dwain.c (5/15/2013)


    Sorry to disappoint you guys but I wasn't able to come up with anything.

    My gut was telling me an rCTE wouldn't do it and the set-based loop I tried wouldn't resolve it out properly either.

    Of course, I could be wrong as I'm a bit out of practice writing rCTEs! ๐Ÿ™‚

    I'm not surprised, Dwain. It's quite tricky. The more obvious methods like MAX() OVER() won't work when you expect them to, in the recursive part.

    โ€œWrite the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.โ€ - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden