Recall & Review
beginner
What is a window function in SQL?
A window function performs a calculation across a set of table rows related to the current row without collapsing the rows into a single output row.
Click to reveal answer
beginner
How do window functions differ from aggregate functions?
Aggregate functions group rows and return one result per group, while window functions keep all rows and add calculated values alongside each row.
Click to reveal answer
intermediate
Why are window functions powerful for data analysis?
They allow calculations like running totals, rankings, and moving averages without losing row-level detail, making complex queries simpler and more efficient.
Click to reveal answer
beginner
What does the OVER() clause do in a window function?
The OVER() clause defines the window or set of rows the function operates on, specifying partitioning and ordering without grouping rows.
Click to reveal answer
beginner
Give an example of a common window function use case.
Calculating a running total of sales per month while still showing each individual sale row.
Click to reveal answer
What does a window function allow you to do in SQL?
✗ Incorrect
Window functions calculate values across related rows but keep all rows visible.
Which clause is essential to define the window for a window function?
✗ Incorrect
The OVER() clause specifies the window or set of rows the function works on.
What is a key advantage of window functions over aggregate functions?
✗ Incorrect
Window functions keep all rows and add calculated columns without grouping.
Which of these is a common use of window functions?
✗ Incorrect
Running totals are a classic example of window function use.
Can window functions be used without grouping rows?
✗ Incorrect
Window functions work on rows without grouping or collapsing them.
Explain why window functions are powerful and how they differ from aggregate functions.
Think about how window functions add extra info without losing original rows.
You got /5 concepts.
Describe a real-life scenario where using a window function would be better than a simple aggregate.
Imagine you want to see each sale and also the total sales so far.
You got /4 concepts.