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 |
|
chandra_ags
Starting Member
1 Post |
Posted - 2009-09-09 : 01:41:24
|
| I have 2 tables shown as below:SID | Personnel | Remarks |1 me good2 he bad3 she averagePID | SID | Attribute | Rate |1 1 1 42 1 2 33 1 3 44 1 4 3And I want to generate this resultResult:Personnel | Attribute1 | Attribute2| Attribute3 | Attribute4 | Remarks me 4(Rate) 3(Rate) 4(Rate) 3(Rate) goodis this possible? need help....thanks in advance...Chan Chan |
|
|
Sachin.Nand
2937 Posts |
Posted - 2009-09-09 : 02:34:53
|
| Are the rate ids going to be static?PBUH |
 |
|
|
Nageswar9
Aged Yak Warrior
600 Posts |
Posted - 2009-09-09 : 03:00:02
|
| Hi,SELECT t.personnel,max([1]) AS Attribute1 ,max([2]) AS Attribute2, max([3]) AS Attribute3, max([4]) AS 'Attribute4',t.remarksFROM @TEMP t inner join @TEMP1 t1 as t.sid = t1.sidPIVOT ( MAX(Rate) for Attribute in ( [1],[2],[3],[4]))p GROUP BY t.personnel,t.remarks |
 |
|
|
|
|
|