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 |
|
a2l2en
Starting Member
11 Posts |
Posted - 2007-06-26 : 16:44:14
|
| Is there a way to transpose a table??I need to transpose the data in the following table. I don't know who created this table or why they did it this way... but it is what it is... Customer_Contract_tableCustomerID Customer_Name Disposalfee Disp_chrg Engine1234 Toyota Dealership 6cyl1234 Toyota Dealership 4cyl1234 Toyota Dealership Battery $9.001234 Toyota Dealership Oil $3.001234 Toyota Dealership Tire $2.001122 Honda Dealership 6cyl1122 Honda Dealership 4cyl5566 CarMax 6cyl5566 CarMax 4cyl5566 CarMax Battery $8.005566 CarMax Oil $2.00The output has to be one line per customer... Or look something like this:CustomerID, customer_name, Battery_Disposal, Battery_disp_charge, Oil_Disposal, Oil_Disposal_charge, Tire_Disposal, Tire_Disposal_charge, 6cylengine, 4cylengineIs this possible? |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-06-27 : 00:12:36
|
| Read about Cross-tab reports in sql server help fileMadhivananFailing to plan is Planning to fail |
 |
|
|
dan18ro
Starting Member
1 Post |
Posted - 2007-06-27 : 07:55:41
|
| Try using PIVOT function...I don't remember the parameters but it works...:) |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-06-27 : 08:49:35
|
quote: Originally posted by dan18ro Try using PIVOT function...I don't remember the parameters but it works...:)
Yes. PIVOT will do that. I forget that this is posted in 2005 Forum MadhivananFailing to plan is Planning to fail |
 |
|
|
a2l2en
Starting Member
11 Posts |
Posted - 2007-06-27 : 12:02:13
|
| Yes! The pivot table worked. Thanks! |
 |
|
|
|
|
|