Home Forums SQL Server 2005 T-SQL (SS2K5) Replacing NULL with 0 when using the Pivot operator RE: Replacing NULL with 0 when using the Pivot operator

  • Well, you can do something like this:

    ;with CTE as

    (SELECT *

    FROM #office_info_by_location_id

    PIVOT (MAX(total_offices) FOR month IN ([2008-03],[2008-04])) AS temp)

    select location_name,

    isnull([2008-03], 0) as [2008-03],

    isnull([2008-04], 0) as [2008-04]

    from cte

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon