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 |
|
rajukurian
Starting Member
8 Posts |
Posted - 2008-09-11 : 11:25:07
|
| Hi,I am facing problem while shifting one row into column.My table is like this.ID COSTSET COST1 1 1.231 2 1.342 1 2.872 2 2.90-====I want the output likeID COSTSET1 COSTSET21 1.23 1.342 2.87 2.90any help will be appriciate.ThanksRK |
|
|
Vinnie881
Master Smack Fu Yak Hacker
1231 Posts |
Posted - 2008-09-11 : 18:34:36
|
[code]Select ID, [1] as CostSet1, [2] as CostSet2from(Select 1 as ID, 1 as CostSet, 1.23 as Cost Union Allselect 1, 2, 1.34 Union Allselect 2, 1, 2.87 Union Allselect 2, 2, 2.90) aPivot(Sum(Cost)for CostSet in ([1],[2]) ) p[/code] Success is 10% Intelligence, 70% Determination, and 22% Stupidity.\_/ _/ _/\_/ _/\_/ _/ _/- 881 |
 |
|
|
|
|
|