I am trying to save the output of below 'WITH' sub-query to a csv file.
WITH mer9 AS (
SELECT *,
substring(seq_window_mut_9mers, split9.start, 9)
FROM split9
),
mer23 AS (
SELECT *,
substring(seq_window_mut_23mers, split23.start, 23)
FROM split23
),
dataset AS (
SELECT *
FROM table
INNER JOIN mer9 ON mer9.seq_window_mut_9mers = table.seq_window_mut_9mers
INNER JOIN mer23 ON mer23.seq_window_mut_23mers = table.seq_window_mut_23mers
)
COPY (SELECT * FROM dataset) TO '/tmp/filename.csv' (format CSV);
After running the query, I am getting an error:
[Code: 0, SQL State: 42601] ERROR: syntax error at or near "COPY"
Position: 3566 [Script position: 3566 - 3570]