Bird
0
0

You wrote this query to get total AWS costs by month: SELECT month, SUM(cost) FROM billing ORDER BY month; but it returns an error. What is the likely cause?

medium📝 Debug Q6 of 15
AWS - Account and Billing
You wrote this query to get total AWS costs by month: SELECT month, SUM(cost) FROM billing ORDER BY month; but it returns an error. What is the likely cause?
AORDER BY cannot be used with GROUP BY
Bmonth is not a valid column
CMissing alias for SUM(cost)
DGROUP BY clause is missing
Step-by-Step Solution
Solution:
  1. Step 1: Check SQL syntax for aggregation

    When selecting non-aggregated columns like 'month' alongside SUM(cost), GROUP BY month is required.
  2. Step 2: Confirm other clauses are correct

    Alias not required, ORDER BY valid, month assumed valid.
  3. Final Answer:

    GROUP BY clause is missing -> Option D
  4. Quick Check:

    Aggregates with grouped columns need GROUP BY [OK]
Quick Trick: Always use GROUP BY with aggregates when selecting grouped columns [OK]
Common Mistakes:
  • Forgetting GROUP BY
  • Assuming ORDER BY disallowed with GROUP BY

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes