Skip to course content
Free SQL course

SQL for Data Analysis and AI

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?

2. ROW_NUMBER() versus RANK() on tied values:

3. PARTITION BY does what?

4. A running total returns wrong values. The most common cause is…

5. Why can't you filter on a window function in WHERE?

---

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.