Bird
0
0

Identify the error in this SQL snippet:

medium📝 Debug Q6 of 15
SQL - Common Table Expressions (CTEs)
Identify the error in this SQL snippet:
WITH SalesCTE AS SELECT ProductID, SUM(Quantity) FROM Sales GROUP BY ProductID SELECT * FROM SalesCTE;
AMissing parentheses around the CTE query
BCTE name is invalid
CMissing alias for SUM(Quantity)
DCTE cannot use GROUP BY
Step-by-Step Solution
Solution:
  1. Step 1: Check CTE syntax

    The CTE query must be enclosed in parentheses after AS.
  2. Step 2: Validate the given code

    The code misses parentheses around the SELECT statement inside the CTE definition.
  3. Final Answer:

    Missing parentheses around the CTE query -> Option A
  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
  • Thinking GROUP BY is disallowed in CTE
  • Confusing aliasing with syntax errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes