Bird
0
0

Identify the error in this SQL query using a CTE:

medium📝 Debug Q14 of 15
SQL - Common Table Expressions (CTEs)
Identify the error in this SQL query using a CTE:
WITH cte1 AS SELECT * FROM employees SELECT * FROM cte1;
ACTE name cannot be cte1
BMissing parentheses around the CTE's SELECT statement
CSELECT * FROM cte1 should come before WITH clause
DWITH clause cannot be used with SELECT
Step-by-Step Solution
Solution:
  1. Step 1: Check CTE syntax

    The CTE definition must have parentheses around the SELECT query: AS (SELECT ...)
  2. Step 2: Identify missing parentheses

    The query misses parentheses after AS, causing syntax error.
  3. Final Answer:

    Missing parentheses around the CTE's SELECT statement -> Option B
  4. Quick Check:

    CTE query must be in parentheses [OK]
Quick Trick: Always put CTE query inside parentheses after AS [OK]
Common Mistakes:
  • Omitting parentheses around CTE query
  • Placing main SELECT before WITH clause
  • Thinking CTE names have restrictions beyond naming rules

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes