Bird
0
0

Identify the error in this SQL query:

medium📝 Debug Q14 of 15
SQL - Aggregate Functions
Identify the error in this SQL query:
SELECT SUM(price), AVG(price) FROM sales GROUP BY category;
ANo error, query is correct
BCannot use SUM and AVG together
CMissing GROUP BY column in SELECT clause
DGROUP BY should be after WHERE clause
Step-by-Step Solution
Solution:
  1. Step 1: Check GROUP BY usage

    When using GROUP BY category, category must appear in SELECT to show groups.
  2. Step 2: Identify missing column

    Query selects only aggregates but misses category column, causing error or unexpected output.
  3. Final Answer:

    Missing GROUP BY column in SELECT clause -> Option C
  4. Quick Check:

    GROUP BY columns must appear in SELECT [OK]
Quick Trick: Include GROUP BY columns in SELECT list [OK]
Common Mistakes:
MISTAKES
  • Omitting GROUP BY column in SELECT
  • Thinking SUM and AVG can't be combined
  • Misplacing GROUP BY clause

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes