Bird
0
0

Identify the issue in this query:

medium📝 Debug Q7 of 15
PostgreSQL - Set Operations and Advanced Queries
Identify the issue in this query:
SELECT * FROM VALUES (3, 'cat'), (4, 'dog') AS pets(id, name);
AVALUES must be enclosed in parentheses and used as a table expression
BColumn aliases cannot be used with VALUES
CVALUES cannot contain mixed data types
DThe AS keyword is not allowed with VALUES
Step-by-Step Solution
Solution:
  1. Step 1: Analyze syntax

    VALUES must be enclosed in parentheses and used as a subquery or table expression.
  2. Step 2: Check query structure

    The query misses parentheses around VALUES rows, causing syntax error.
  3. Final Answer:

    VALUES must be enclosed in parentheses and used as a table expression -> Option A
  4. Quick Check:

    VALUES needs parentheses and FROM clause [OK]
Quick Trick: Always wrap VALUES in parentheses and FROM [OK]
Common Mistakes:
  • Omitting parentheses around VALUES
  • Misplacing AS keyword
  • Incorrect aliasing of columns

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes