Need help on Getting Result from row to column

  • Hi

    I need help to build the below data to my requirement

    i have table having the following data's

    NoofLive Action Sold Ratio EffDt

    10-49 43 0 0 1/1/2008

    50-99 62 0 0 1/1/2008

    100-199 73 0 0 1/1/2008

    200-299 17 1 0.059 1/1/2008

    300-499 25 0 0 1/1/2008

    500-999 21 0 0 1/1/2008

    1000+ 45 0 0 1/1/2008

    100-199 11 1 0.091 2/1/2008

    1000+ 1 0 0 2/1/2008

    100-199 17 0 0 3/1/2008

    500-999 2 0 0 3/1/2008

    EffDt = (Jan-08,Feb-08,Mar-08)

    I want creat result as follows from the above data's

    Jan-08 Feb-08 Mar-08

    Eligible Lives Quoted Sold Close Ratio Quoted Sold Close Ratio Quoted Sold Close Ratio

    10 - 49 43 0 0 0 0 0 0 0 0

    50 - 99 62 0 0 0 0 0 0 0 0

    100 - 199 73 0 0 11 0 0 0 0 0

    200 - 299 17 1 0.059 0 0 0 17 0 0

    300 - 499 25 0 0 0 0 0 0 0 0

    500 - 999 21 0 0 0 0 0 0 0 0

    1000+ 45 0 0 1 0 0 2 0 0

    Please anybody can help build a query to generate the above result.

    Thanks in advance

    sthanika

  • Look up Pivot in Books online. I think it may do what you want.

    Also, take a look at this article. It's not completely clear which columns are which in your example.

    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply