-
Hello. How would I create an alias for temporary table in such query? select "id" from (values (1), (2)) as tmptable("id") The goal is combining results of the CTE to be inserted, I have made the jet statement for this query except for the WITH balance_cte AS (
INSERT INTO md.balances("user_id", "amount")
VALUES
(1134, 1000),
(1178, 1000),
(1143, 1000)
RETURNING md.balances."id" AS "tx_id"
), tx_rows AS (
SELECT "tx_id", ROW_NUMBER() OVER() AS "row_n" FROM balance_cte
), rewards AS (
SELECT "task_id", ROW_NUMBER() OVER() AS "row_n" FROM
(VALUES (355), (356), (357))
AS tasks("task_id")
)
INSERT INTO md.user_rewards ("tx_id", "task_id")
SELECT "t"."tx_id", "w"."task_id"
FROM tx_rows AS "t" JOIN rewards AS "w" ON "w"."row_n" = "t"."row_n"
RETURNING md.user_rewards."id" |
Beta Was this translation helpful? Give feedback.
Answered by
houten11
Nov 23, 2023
Replies: 1 comment
-
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
difof
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
VALUES
is not supported, but there is a workaround - #69 (comment)