Multi Pivoting on single Source data

Posted by Nev_Rahd on Stack Overflow See other posts from Stack Overflow or by Nev_Rahd
Published on 2010-05-19T01:46:09Z Indexed on 2010/05/19 1:50 UTC
Read the original article Hit count: 279

Filed under:
|
|

I am trying to mutlipivot source data (as below )

alt text

want results as single column (as below)

alt text

My query so far is

SELECT  *
FROM    ( SELECT    *
      FROM      ( SELECT    NK,
                            DC,
                            VERSION,
                            GEV
                  FROM      MULTIPIVOT
                ) SRC PIVOT ( MAX(GEV) FOR DC IN ( [10], [11], [12], [18] ) ) AS PVT
    ) SRC PIVOT ( MAX([18]) FOR VERSION IN ( [2006], [2007], [2008],[2009] ) )AS PVT

which outputs results as

alt text

what is the way to get this as single row?

Thanks

© Stack Overflow or respective owner

Related posts about sql

Related posts about pivot