|
With the use of the VALUES statement you can omit the intermediate table. SELECT [group], Sum([A]*[percentage]) as [A] , Sum([B]*[percentage]) as [B] , Sum([C]*[percentage]) as [C] , Sum([D]*[percentage]) as [D] FROM [test] INNER JOIN ( VALUES ('Group 1', 'T1', 1) , ('Group 1', 'T2', 0.5) , ('Group 1', 'T3', 0.25) , ('Group 2', 'T2', 0.5) , ('Group 2', 'T3', 0.75) , ('Group 2', 'T4', 1) , ('Group 3', 'T5', 1) AS ([group], [category], [percentage]) ) ON [test].[name] = [category] GROUP BY [group]
http://www.mppng.nl/manifold/pointlabeler |