SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Need help on Getting Result from row to column


Need help on Getting Result from row to column

Author
Message
muthumeerakumar
muthumeerakumar
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
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
GilaMonster
GilaMonster
SSC Guru
SSC Guru (224K reputation)SSC Guru (224K reputation)SSC Guru (224K reputation)SSC Guru (224K reputation)SSC Guru (224K reputation)SSC Guru (224K reputation)SSC Guru (224K reputation)SSC Guru (224K reputation)

Group: General Forum Members
Points: 224777 Visits: 46321
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


Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search