Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
moseph
Starting Member
8 Posts |
Posted - 2010-06-07 : 21:40:54
|
| Hi, i am new to pivoting and transposing tables so here goes:I have a table with 2 columns :column_header | column_value Available | yes Type | used Maintained By | Drax.IncI want this in this form:Available | Type | Maintained By yes | used | Drax.Inc any suggestions |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2010-06-08 : 05:58:08
|
| Look up PIVOT, there are loads of examples strewn over the interweb. |
 |
|
|
moseph
Starting Member
8 Posts |
Posted - 2010-06-08 : 11:41:48
|
quote: Originally posted by RickD Look up PIVOT, there are loads of examples strewn over the interweb.
they all use the darn aggregate function, i dont have any numerical columns in my example. |
 |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2010-06-08 : 11:48:08
|
Something like thisselect max(case when column_header = 'Available' then column_value else null end) as [Available],max(case when column_header = 'Type' then column_value else null end) as [Type],max(case when column_header = 'Maintained By' then column_value else null end) as [Maintained By]from tableA |
 |
|
|
moseph
Starting Member
8 Posts |
Posted - 2010-06-08 : 11:54:47
|
quote: Originally posted by vijayisonly Something like thisselect max(case when column_header = 'Available' then column_value else null end) as [Available],max(case when column_header = 'Type' then column_value else null end) as [Type],max(case when column_header = 'Maintained By' then column_value else null end) as [Maintained By]from tableA
is there a way where its not hard coded? |
 |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2010-06-08 : 12:21:50
|
| Search for Dynamic Cross Tab here. |
 |
|
|
moseph
Starting Member
8 Posts |
Posted - 2010-06-08 : 13:19:48
|
quote: Originally posted by vijayisonly Search for Dynamic Cross Tab here.
all the examples use the aggregate functions, is there NO example without the aggregate functions?? |
 |
|
|
moseph
Starting Member
8 Posts |
Posted - 2010-06-08 : 13:30:17
|
| ok figured it out, thnx for the help |
 |
|
|
|
|
|