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 |
|
vijays3
Constraint Violating Yak Guru
354 Posts |
Posted - 2010-12-02 : 08:18:32
|
| Hi allI am in trouble because i have to change the display of the data in y table .please suggest me how to do this.My table containing data in below order data1 ,data2 ,data3 are column names data 1 data2 data3 apple1 orange1 1 apple2 orange1 2 apple2 orange3 3but i need to change it in below format1 2 3orange1 orange1 orange3apple1 apple2 apple2please advise me on this |
|
|
ahmeds08
Aged Yak Warrior
737 Posts |
Posted - 2010-12-03 : 01:14:12
|
| you can do it by using pivot function |
 |
|
|
ahmeds08
Aged Yak Warrior
737 Posts |
Posted - 2010-12-03 : 01:16:39
|
| replace this query with your columns SELECT [xxx], [yyy], [zzz]FROM ( SELECT [emp_name], [emp_id]FROM employee ) p PIVOT ( max(emp_id)FOR [emp_name] IN ([xxx],[yyy],[zzz]) ) AS pvt |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|