question

ichange avatar image
ichange asked

Pivot a table with multiple measures

![alt text][1]Hi all Please can some one suggest me a way of pivoting a table that has more than one measure. See the screenshot, The first table is the table I have and the second table is how I want to see the data. Here is what I have tried, I can only use one measure in there which is not what I want. Thanks in advance! SELECT Name , [Maths] AS [Maths_Marks1] , [Science] AS [Science_Marks1] FROM ( SELECT Name , Subject , Marks1 FROM #have ) AS SourceTable PIVOT ( SUM(Marks1) FOR Subject IN ( [Maths], [Science] ) ) as PivotTable1 [1]: /storage/temp/4135-pivot.jpg
sqltsql
pivot.jpg (21.7 KiB)
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
tzvikl avatar image
tzvikl answered
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.