Free 30-day beta access · no payment · progress saved
The business problem
A report must rank sales and compare each month with the previous one without collapsing detail.
What you will be able to do
Use OVER, PARTITION BY, ranking functions, LAG and running totals.
Define a window
Rank within a group
Compare two periods
Build a running total
Scope of this micro-course
This micro-course targets one focused skill. It does not replace a complete path or server administration training.
Prerequisites
Aggregations, GROUP BY and CTEs
Project and practice
10 verified exercises are available. A business project is included.
Focused path
Your programme, in order.
Content remains centralised: completing an activity here also updates the path that contains it.
Micro-lessons
01
The problem to solve before syntax
A moving average can change when two lines share the same date or a month is missing. The query executes, but the implicit frame does not necessarily correspond to the business question.
PARTITION BY restarts the calculation by group, ORDER BY defines the sequence and the frame defines the lines visible from the current line. Explicitly write `ROWS BETWEEN` when reasoning in observations.
Rank results in each region — software subscriptions training scenario
Rank results in each region using a software subscription dataset designed to control level of detail and variance. You must produce the result, check it on the source data and explain what it allows you to decide in this software subscription.
Compare each month to the previous one — software subscriptions · training scenario
Compare each month to the previous one using a software subscription dataset designed to monitor level of detail and variances. You must produce the result, check it on the source data and explain what it allows you to decide in this software subscription.
Building a monthly rollup — software subscriptions · training scenario
Construct a monthly total from a software subscription dataset designed to control the level of detail and variances. You must produce the result, check it on the source data and explain what it allows you to decide in this software subscription.
Smoothing a two-month trend — software subscriptions · training scenario
Smooth a two-month trend from a software subscription dataset designed to control the level of detail and variances. You must produce the result, check it on the source data and explain what it allows you to decide in this software subscription.
Produce conditional KPIs by region — software subscriptions · training scenario
Produce conditional KPIs by region from a software subscription dataset designed to monitor level of detail and variances. You must produce the result, check it on the source data and explain what it allows you to decide in this software subscription.
Measure the contribution of each line — software subscriptions · training scenario
Measure the contribution of each line from a software subscription dataset designed to monitor level of detail and variances. You must produce the result, check it on the source data and explain what it allows you to decide in this software subscription.
Keep top two lines per region — software subscriptions training scenario
Maintain the top two rows per region from a software subscription dataset designed to control level of detail and variances. You must produce the result, check it on the source data and explain what it allows you to decide in this software subscription.
Divide results into quartiles — software subscriptions · training scenario
Divide results into quartiles from a software subscription dataset designed to control level of detail and variance. You must produce the result, check it on the source data and explain what it allows you to decide in this software subscription.
Compare each value to its regional average — software subscriptions · training scenario
Compare each value to its regional average using a software subscription dataset designed to control the level of detail and variances. You must produce the result, check it on the source data and explain what it allows you to decide in this software subscription.
Detect duplicate business references — software subscriptions training scenario
Detect duplicate business references from a software subscription dataset designed to control level of detail and discrepancies. You must produce the result, check it on the source data and explain what it allows you to decide in this software subscription.