I am trying to define a CTE and then immediately use it in a WHERE clause using the IN operator.
This does NOT work.
WITH T AS (SELECT 1)
SELECT 2 WHERE 1 IN T;
This does work, but I need to add a SELECT.
WITH T AS (SELECT 1)
SELECT 2 WHERE 1 IN (SELECT * FROM T);
Is there a way to get rid of the last SELECT?
I am using this query in the context of Foreign Data wrappers. The addition of the last select prevents the "in-lining" of the intermediate results.