私はSQLを初めて使用するので、愚かな質問かもしれませんが、Insert IntoでWith句を使用する可能性はありますか? または、一般的な回避策はありますか? 私は次のようなことを意味します:
With helper_table As (
Select * From dummy2
)
Insert Into dummy1 Values (Select t.a From helper_table t Where t.a = 'X' );
どうも!
私の例はあまりにもダミーなので、拡張コードを追加します (これまでの回答は thx)。
INSERT
INTO dummy values (a,b) //more values
WITH helper_table AS
(
SELECT *
FROM dummy2
)
WITH helper_table2 AS //from more tables
(
SELECT *
FROM dummy3
)
SELECT t.value as a, t2.value as b
FROM helper_table t
join helper_table t2 on t.value = t2.value //some join
WHERE t.value = 'X' and t2.value = 'X' //other stuff