Module 07 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. How does a window function differ from GROUP BY?
- A. It is faster
- B. It computes across a set of rows without collapsing them
- C. It only works on dates
- D. It replaces JOIN
2. ROW_NUMBER() versus RANK() on tied values:
- A. Identical
- B. ROW_NUMBER always gives distinct numbers; RANK gives ties the same rank and skips subsequent numbers
- C. RANK is random
- D. ROW_NUMBER skips numbers
3. PARTITION BY does what?
- A. Splits the table into physical files
- B. Restarts the window calculation for each group
- C. Filters rows
- D. Sorts the output
4. A running total returns wrong values. The most common cause is…
- A. Missing index
- B. No deterministic ORDER BY inside the window
- C. Wrong data type
- D. Too many rows
5. Why can't you filter on a window function in WHERE?
- A. It is a syntax preference
- B. Window functions are computed after WHERE, so you must wrap the query or use QUALIFY
- C. You can
- D. They only work in ORDER BY
---
Answer Key and Explanations
Check these only after attempting every question.
1. B - It computes across a set of rows without collapsing them
The row count is preserved, so you keep detail alongside the aggregate.
2. B - ROW_NUMBER always gives distinct numbers; RANK gives ties the same rank and skips subsequent numbers
Choosing the wrong one changes which rows a 'top N per group' filter returns.
3. B - Restarts the window calculation for each group
It defines the boundary within which the window function operates.
4. B - No deterministic ORDER BY inside the window
A running total is only meaningful in a defined order; ties or missing ORDER BY make it unstable.
5. B - Window functions are computed after WHERE, so you must wrap the query or use QUALIFY
Understanding evaluation order explains a very common 'invalid use of window function' error.
Practical Check
Apply this module to your own work: complete the module activity for *Window Functions for Ranking, Running Totals, and Cohorts*, 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.
