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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2000-09-07 : 15:41:19
|
David writes "I have a table with three columns:
OrgCode TaskCode Hours ------- -------- ----- 1 1 2.0 1 2 4.5 2 1 1.0 2 2 3.0 3 1 4.0 3 2 2.1
I am trying to arrange the data as follows: OrgCodes TaskCode 1 2 3 -------- --- --- --- 1 2.0 1.0 4.0 2 4.5 3.0 2.1
If the orgcodes were always the same, I know this should be simple: (case orgcode when 1 then hours else 0 end) col1, (case orgcode when 2 then hours else 0 end) col2, (case orgcode when 3 then hours else 0 end) col3
The trick is the org codes change. What's more, even the number of org codes change. Is there some way to dynamically determine the org code columns? I've done this in ms-access before (using the TRANSFORM...PIVOT syntax), but can you do this on SQL server? I'm running SQL Server 7.0. Thanks in advance for your help."
|
|
|
|
|
|