The correct Postgres syntax would be:
SELECT * FROM (VALUES (1)) AS q (col1);
A set of parentheses was missing.
But Redshift does not support free-standing VALUES
expressions (outside of INSERT
commands). So, for a single row:
SELECT * FROM (SELECT 1) AS q (col1);
For multiple rows (without using UNION ALL
like requested) you can use a temporary table:
CREATE TEMP TABLE q(col1 int);
INSERT INTO q(col1)
VALUES (1), (2), (3);
SELECT * FROM q;
The manual:
A temporary table is automatically dropped at the end of the session
in which it was created.
If UNION ALL
is an option:
SELECT 1 AS col1
UNION ALL SELECT 2
UNION ALL SELECT 3;