Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Need help on Getting Result from row to column Expand / Collapse
Author
Message
Posted Thursday, January 17, 2008 4:47 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, March 4, 2008 12:21 AM
Points: 1, Visits: 9
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







Post #444225
Posted Thursday, January 17, 2008 5:15 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 4:15 AM
Points: 39,975, Visits: 36,334
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 2008, MVP
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

Post #444235
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse