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?
- A. They are interchangeable
- B. WHERE filters rows before grouping; HAVING filters groups after aggregation
- C. HAVING is faster
- D. WHERE only works on numbers
2. GROUP BY changes the grain of your result to…
- A. One row per source row
- B. One row per distinct combination of the grouped columns
- C. One row total
- D. It does not change grain
3. COUNT(*) versus COUNT(column) differ because…
- A. They are identical
- B. COUNT(column) skips NULLs in that column
- C. COUNT(*) is deprecated
- D. COUNT(column) counts distinct values
4. You group by customer_id and also select customer_name without aggregating it. What is the risk?
- A. No risk
- B. Some engines error; others pick an arbitrary value if name is not functionally dependent on the group
- C. It doubles the rows
- D. It sorts the output
5. An average of averages (AVG over already-averaged rows) is wrong when…
- A. Never
- B. The underlying groups have different sizes
- C. The values are integers
- D. There are more than 10 groups
---
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.
