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 |
|
MLS
Starting Member
1 Post |
Posted - 2010-04-16 : 11:04:21
|
| Hi. I have a large table, This is a sample data set from table1. How can I get table 2 from table1 to have one unique record for each person, please note that column headers between Table1 and table 2 are different:Table 1 Name Color Age Enrolled Jo red 24 Y Jo blue 24 Y Ray red 31 Y MIke blue 28 N Table 2 Name Red Blue Age EnrolledJo red blue 24 YRay red 31 YMike blue 28 N Thanks. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-04-19 : 04:31:46
|
| [code]INSERT INTO Table2SELECT Name,MAX(CASE WHEN Color='red' THEN Color ELSE NULL END),MAX(CASE WHEN Color='blue' THEN Color ELSE NULL END),Age,EnrolledFROM Table1GROUP BY Name,Age,Enrolled[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|