I have a Pivot data which I need to insert into a table. I can get the data inserted into the desired table if I run it as SQL, but When I try to run it as Stored procedure, data does not get inserted. Here is my query:
Begin
Delete from TEMP_PIVOTTABLE;
with pivot_data as (
SELECT COL1,COL2,COL13,COL4 FROM TEMP_TABLE1
)
Insert into TEMP_PIVOTTABLE (COL1,COL2,COL13,COL4) -- I AM GETTING SYNTAX ERROR (EXPECTED, SELECT)
select * from pivot_data
PIVOT
(
sum (COL3) FOR COL2 IN ('Client','Yes','No')
)
order by COL1;
END;