CREATE TABLE #Temp([Group] CHAR(1),Name CHAR(1),Value INT)
INSERT INTO #Temp([Group],Name,Value) values
('p','a',1),
('p','b',2),
('p','c',3),
('p','d',4),
('q','a',5),
('q','b',6),
('q','d',7),
('r','a',8),
('r','b',9),
('r','c',10),
('r','d',11)
SELECT [Group],a,b,c,d FROM
(
SELECT [GROUP],Name,value FROM #Temp
) AS P
Pivot
(
sum(value)
for name in([a],,[c],[d])
) as pvt
order by pvt.[Group]