• WOW!!!!

    It doesn't happen that often to have somebody posting a question as perfect as you did!!!

    There's nothing more to say than GREAT JOB!!

    And here's how I'd do it:

    SELECT

    city,

    zip,

    SUM(CASE WHEN LOB='PW' THEN ServiceCount ELSE 0 END) AS PW,

    SUM(CASE WHEN LOB='CWS' THEN ServiceCount ELSE 0 END) AS CWS,

    SUM(CASE WHEN LOB='IMG' THEN ServiceCount ELSE 0 END) AS IMG

    FROM @t1

    GROUP BY city,zip

    ORDER BY city,zip DESC

    The concept is based on the CrossTab article referenced in my signature. Once you're familiar with the concept I recommend to have a look at the DynamicCrossTab article also referenced in my sig. It might come in handy if you ever need to make that query using a flexible number of LOB values....



    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]