• bj_shenglong (12/5/2012)


    There is a particular problem, let's' say, we just want to find out who sold more then 2 each month in at least two consecutive months and when.

    For the above sample, below recursion would work. Also, recursion will stop immediately when it reaches the first qualified date.

    Although they can be fast, recursive CTEs are still procedural in nature. The only way to know for sure is to do a test.

    {Edit} Was distracted by a code promotion going on at work and I see that MickyT made just such a test. Thank you, good Sir!

    --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)