I have a script with a series of CTEs. I want to update a database table from the final CTE, but I can’t seem to do that. How can I update a db table using data from my CTE?
Simplified example of what I’m trying to do:
WITH cte_2 AS (
SELECT
ID
, MEMBER_STATE
, PLAN_CODE
FROM cte_1
)
INSERT INTO database_table (ID, MEMBER_STATE, PLAN_CODE)
SELECT
ID
, MEMBER_STATE
, PLAN_CODE
FROM cte_2
New contributor
Emma Keefe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.