I have 'book value' and 'Asset type' columns with set asset type values - 'NCD','GSEC' and 'EQU' . I want to use unpivot and convert them from rows to cols using UNPIVOT but i am getting errors as follows.
Msg 207, Level 16, State 1, Line 267 Invalid column name 'GSEC'.
Msg 207, Level 16, State 1, Line 267 Invalid column name 'EQU'.
Msg 265, Level 16, State 1, Line 267
The column name "Book Value" specified in the UNPIVOT operator conflicts with the existing column name in the UNPIVOT argument.
Msg 265, Level 16, State 1, Line 267
The column name "Asset Type" specified in the UNPIVOT operator conflicts with the existing column name in the UNPIVOT argument.
Msg 8156, Level 16, State 1, Line 267 The column 'Book Value' was specified multiple times for 'UNPVT'.
This is the code snippet i am using
Select [Book Value],[Asset Type]
FROM [DBname].[dbo].[Final Base Data-4]
UNPIVOT([Book Value] For [Asset Type]
in ([NCD],[GSEC],[EQU])) AS UNPVT;