Bird
0
0

Identify the error in the following query:

medium📝 Debug Q6 of 15
PostgreSQL - Subqueries in PostgreSQL
Identify the error in the following query:
SELECT * FROM sales WHERE customer_id IN SELECT id FROM customers WHERE country = 'USA';
AIncorrect table name 'sales'
BMissing parentheses around the subquery after IN
CUsing IN instead of EXISTS
DNo error, query is correct
Step-by-Step Solution
Solution:
  1. Step 1: Check syntax of IN with subquery

    The subquery must be enclosed in parentheses after IN.
  2. Step 2: Analyze the query

    The query lacks parentheses around the subquery, causing a syntax error.
  3. Final Answer:

    Missing parentheses around the subquery after IN -> Option B
  4. Quick Check:

    IN requires parentheses around subqueries [OK]
Quick Trick: Always use parentheses around subqueries with IN [OK]
Common Mistakes:
  • Omitting parentheses around subqueries
  • Confusing IN with other operators
  • Assuming table names cause syntax errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes