0

I am having a sample query data table:

Sample data

I want my output table to look like:

Output sample data

I tried by using pivot operator but its not possible to sum them all.

River
  • 8,585
  • 14
  • 54
  • 67
Saad
  • 259
  • 1
  • 3
  • 3
  • The sample data and Output Sample data highlighted in blue are the links to the images of the respective tables – Saad Jun 28 '16 at 09:38
  • 3
    http://stackoverflow.com/questions/38067490/in-sql-sever-how-to-pivot-for-multiple-columns .. same question been again asked !!!! – Malcolm Jun 28 '16 at 09:40

1 Answers1

0
SELECT 
    * 
FROM
    (
        SELECT * FROM woddb.cityStock_Unpivot
    ) AS tblCity
    UNPIVOT
    (
        OutputValue FOR [OutputFieldName] IN (Sales, stock, [Target])
    ) AS UNPVT
    PIVOT
    (
        SUM(OutputValue)
        For Category IN (Panel,ac,ref)
    ) AS PVT
Community
  • 1
  • 1