• I think this might do it...

    SELECT hi.Date,

    hi.Area,

    CASE WHEN hi.Amount = 0 THEN ISNULL(lo.Amount,0) ELSE hi.Amount END AS Amount,

    hi.AOD

    FROM MyTable lo

    RIGHT JOIN MyTable hi ON lo.Date = hi.Date

    AND lo.AOD = DATEADD(mm,-1,hi.AOD)

    ORDER BY hi.AOD,hi.Date

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