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 |
|
guptaalok12
Starting Member
5 Posts |
Posted - 2008-09-23 : 04:23:25
|
| Emp-----ID Name1 x1 P2 y2 Q3 WEmp_DataId Name-1 Name-21 x P2 y Q3 wabove is my tables (Emp ),And the I want the Resulting Data in the (Emp_Data) format.is this possible Pls Help........Thanks in advance-----alokgupta |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-23 : 04:53:43
|
| [code]SELECT t.ID,MAX(CASE WHEN t.Seq=1 THEN t.Name ELSE NULL END) AS Name_1,MAX(CASE WHEN t.Seq=2 THEN t.Name ELSE NULL END) AS Name_2FROM (SELECT ROW_NUMBER() OVER(PARTITION BY ID Order BY Name) AS Seq,* FROM Emp)tGROUP BY t.ID[/code] |
 |
|
|
|
|
|