• Thanks to Gail for stopping me to post in the wrong thread just in time!!

    And here's what I was about to post "over there":

    (Note: I second Gus preferring to do it on the app side though...)

    If it needs to be dynamic please have a look at the DynamicCrossTab article referenced in my signature.

    DECLARE @tbl TABLE

    ([MONTH] INT, [COUNT] INT, code VARCHAR(30)

    )

    INSERT INTO @tbl

    SELECT 6, 8425, 'DELIVERY' UNION ALL

    SELECT 6, 20, 'CANCELLED'

    -- option 1: PIVOT

    SELECT [MONTH],[DELIVERY], [CANCELLED]

    FROM

    (

    SELECT [MONTH] , [COUNT] , code

    FROM @tbl

    ) p

    PIVOT

    (

    SUM ([COUNT])

    FOR code IN( [DELIVERY], [CANCELLED])

    ) AS pvt

    -- option 2: "classic" CASE statement

    SELECT

    [MONTH],

    SUM(CASE WHEN code ='DELIVERY' THEN [COUNT] ELSE 0 END) AS [DELIVERY],

    SUM(CASE WHEN code ='CANCELLED' THEN [COUNT] ELSE 0 END) AS [CANCELLED]

    FROM @tbl

    GROUP BY [MONTH]



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]