• balars_2000 (6/9/2009)


    I would display 0's to indicate there was no data during that particular week.

    --Ta

    Then you need a complete list of dates to join against for any given year...

    [font="Courier New"]DECLARE @FirstDate DATETIME

     SELECT @FirstDate = '20090104'

     SELECT v.Number AS Week,

            DATEADD(wk, v.Number   ,@FirstDate) AS StartDate,

            DATEADD(wk, v.Number+1 ,@FirstDate) AS NextDate

       FROM Master.dbo.spt_Values v

      WHERE Type = 'P' 

        AND Number BETWEEN 0 AND 51[/font]

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