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 |
KabirPatel
Yak Posting Veteran
54 Posts |
Posted - 2008-11-17 : 10:07:53
|
Hi,I have a table as follows:RuleID | Reference | Sequence-----------------------------1234 Test 11234 More 21234 other 35678 etc.. 1I would like to display the data a follows:Rule ID | Ref 1 | Ref 2 | Ref 3 | Ref 4 ----------------------------------------1234 Test More other null5678 etc.. null null nullHow would I do this?Thanks,Kabir |
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2008-11-17 : 10:26:12
|
select RuleID,max(case when Reference ='Test'or Reference = 'etc..' then Reference else null end)as Ref1,max(case when Reference ='More' then Reference else null end)as Ref2,max(case when Reference ='other'then Reference else null end)as Ref3,max(case........................from tablesgroup by RuleID |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-17 : 11:38:19
|
will reference names be always static? |
 |
|
KabirPatel
Yak Posting Veteran
54 Posts |
Posted - 2008-11-17 : 11:41:26
|
No - afraid not. The control reference value can be anything.Any other ideas? |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-11-18 : 04:41:15
|
http://sqlblogcasts.com/blogs/madhivanan/archive/2007/08/27/dynamic-crosstab-with-multiple-pivot-columns.aspxMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|