Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

156
Views
Using Common Table Expression (CTE) with IN operator

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.

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!