SQLTeam.com | Weblogs | Forums

Converting row data to columns


#1

HI, I've been reading on PIVOT and other ways to transform rows into columns, but am still quite stuck, and could use some help. I've got data like this: (sorry, not sure how to format at this point, so using periods for spacing)

ID Date ....Amount
1 .Jan-15 .100
1 .Feb-15 .100
2 .Feb-15 .150
2 .Mar-15 .150

And need data like this:
ID Jan-15 .Feb-15 .Mar-15
1.. 100 .....100
2 ............. 150 ......150

There can be an undetermined number of values for the date field. Thanks in advance for any advice.

Dan


#2

Try search for Dynamic PIVOT.


#3

thank you, that got me on the right track and I found a good example to work from. I know have a working query on my test data, so confident I can get it to execute on the production database. Thanks.

Dan


#4

Refer below post. Post has similar example you are looking for