October 8, 2014 at 5:40 pm
Hi All,
i'm struggling with one Syntax error , any help is appreciate
CREATE TABLE #ToolCompliance
(
SOFTWAR_ID INT
,CONTROL_CODE VARCHAR(100)
,CONTROL_STATUS VARCHAR(100)
)
INSERT INTO #ToolCompliance
VALUES(1000,'AC','SUCCESS')
,(1000,'CC','FAILED')
,(10000,'VC','SUCCESS')
,(10000,'IC','SUCCESS')
,(10000,'DC','SUCCESS')
,(10000,'BR','FAILED')
SELECT *
FROM (
SELECT
SOFTWAR_ID
,CONTROL_CODE
,CONTROL_STATUS
FROM #ToolCompliance
) as s
PIVOT
(
MAX(CONTROL_STATUS)
FOR [CONTROL_CODE] IN ([AC], [CC], [VC], [IC], [DC], [BR])
)AS pivot
DROP TABLE #ToolCompliance
October 8, 2014 at 5:44 pm
The problem is with your pivot alias. You need to use square brackets if you want to use a reserved word or, even better, change the alias into something less problematic.
October 9, 2014 at 7:05 am
please try this code it is working fine.
SELECT *
FROM (
SELECT
SOFTWAR_ID
,CONTROL_CODE
,CONTROL_STATUS
FROM #ToolCompliance
) as s
PIVOT
(
MAX(CONTROL_STATUS)
FOR [CONTROL_CODE] IN ([AC], [CC], [VC], [IC], [DC], [BR])
)AS [pivot]
October 11, 2014 at 1:00 pm
Thanks Luis , this solved my issue
October 11, 2014 at 1:00 pm
Thanks Bhanu , this solved my issue
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy