0
0
Snowflakecloud~5 mins

Window functions in Snowflake - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a window function in Snowflake?
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
What does the OVER() clause do in a Snowflake window function?
The OVER() clause defines the window or set of rows the function operates on, including partitioning and ordering rules.
Click to reveal answer
intermediate
How does PARTITION BY affect a window function in Snowflake?
PARTITION BY divides the data into groups (partitions) so the window function runs separately within each group.
Click to reveal answer
advanced
What is the difference between ROWS and RANGE in window framing?
ROWS counts physical rows relative to the current row; RANGE considers logical values in the order column, including ties.
Click to reveal answer
beginner
Give an example of a common window function in Snowflake and its use.
ROW_NUMBER() assigns a unique number to each row within a partition, useful for ranking or deduplication.
Click to reveal answer
Which clause is mandatory for a window function in Snowflake?
AOVER()
BWHERE
CGROUP BY
DHAVING
What does PARTITION BY do in a window function?
AFilters rows before calculation
BGroups rows for separate calculations
CSorts rows globally
DLimits output rows
Which window function assigns a unique rank to each row?
ASUM()
BAVG()
CROW_NUMBER()
DCOUNT()
What is the default frame for window functions if not specified?
AROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
BROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
CRANGE BETWEEN CURRENT ROW AND CURRENT ROW
DRANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
Which keyword defines the order of rows in a window function?
AORDER BY
BPARTITION BY
CGROUP BY
DFILTER BY
Explain how window functions differ from aggregate functions in Snowflake.
Think about whether the number of rows changes after applying the function.
You got /4 concepts.
    Describe how to use PARTITION BY and ORDER BY together in a window function and why.
    Consider how you would rank students by class and score.
    You got /4 concepts.