DROP table #temp
create table #temp
(
Rack varchar(200),
Sensor varchar(200),
Diff int
)
INSERT INTO #TEMP VALUES ('R1','TEMP',20)
INSERT INTO #TEMP VALUES ('R1','HUMID',20)
INSERT INTO #TEMP VALUES ('R2','TEMP',25)
INSERT INTO #TEMP VALUES ('R2','HUMID',22)
INSERT INTO #TEMP VALUES ('R3','TEMP',19)
INSERT INTO #TEMP VALUES ('R3','HUMID',10)
SELECT * FROM #temp
SELECT Rack, [TEMP],[HUMID]
FROM #temp
PIVOT (MAX(Diff) FOR Sensor IN ([TEMP],[HUMID])) AS X