Home Forums SQL Server 2012 SQL Server 2012 - T-SQL Evaluating Rows to identify >=3 months of consecutive dates and exclude first and last month RE: Evaluating Rows to identify >=3 months of consecutive dates and exclude first and last month

  • Thank you both for the feedback.

    For those that may not understand how the formula for the "Grp" column works, you can find an explanation of the principle in the article at the following URL.

    http://www.sqlservercentral.com/articles/T-SQL/71550/

    The data in the article is based on contiguous days but as you can see in the code above, the principle applies to virtually any regular temporal resolution.

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