-2

I am looking to run an INSERT into a table using a WITH CLAUSE before the SELECT. I tried putting the WITH before the INSERT and before the SELECT but I am SQL is not liking the formatting.

1 Answers1

1

Here is an example

INSERT
INTO    values (a,b)  //more values
WITH   table AS
    (
    SELECT  *
    FROM    table1
    )
WITH    table2 AS   //from more tables
    (
    SELECT  *
    FROM    table_2
    )         
SELECT  t.value as a, t2.value as b
FROM    table t 
JOIN table2 t2 on t.value = t2.value //some join
WHERE t.value = 'X'   //other stuff
MhQ-6
  • 328
  • 3
  • 11