Skip to course content
Free SQL course

SQL for Data Analysis and AI

Module 04 Knowledge Check

5 questions. Pass mark 4 out of 5. Answer every question before checking the answer key below, then retry after reading the feedback.

1. What is the difference between WHERE and HAVING?

2. GROUP BY changes the grain of your result to…

3. COUNT(*) versus COUNT(column) differ because…

4. You group by customer_id and also select customer_name without aggregating it. What is the risk?

5. An average of averages (AVG over already-averaged rows) is wrong when…

---

Answer Key and Explanations

Check these only after attempting every question.

1. B - WHERE filters rows before grouping; HAVING filters groups after aggregation

Filtering before grouping changes which rows form the groups; filtering after changes which groups survive.

2. B - One row per distinct combination of the grouped columns

Every aggregation redefines what one output row represents - state the new grain.

3. B - COUNT(column) skips NULLs in that column

This distinction is a common source of mismatched totals in reports.

4. B - Some engines error; others pick an arbitrary value if name is not functionally dependent on the group

Selecting a non-grouped, non-aggregated column is either an error or a silent arbitrary pick.

5. B - The underlying groups have different sizes

Unweighted averaging treats a group of 2 the same as a group of 2,000.

Practical Check

Apply this module to your own work: complete the module activity for *Aggregation with GROUP BY and HAVING*, then write one sentence naming what your result shows and one naming what it does not.

Strong Answer Pattern

A strong answer names the task, the evidence used, the check performed, and the remaining limitation. It avoids "proved", "guaranteed", or "always" unless the evidence genuinely supports it.