• sharonsql2013 (8/25/2016)


    I am getting last 4 week numbers in a query - say 31 thru 33.

    How can I rename 31 as week 1 , 32 as week2 , 33 as week 3 and 334 as week4 so it dynamically keeps changing?

    Subtract 30?

    Or, perhaps, (WeekNumber-1)%30 + 1?

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