DataIntermediate 2 to 3 hours

Window Functions for Ranking & Trends

ROW_NUMBER, LAG, and running totals on a time-series dataset.

The Scenario

A SaaS company tracks monthly recurring revenue (MRR) per customer. The finance team wants to rank customers, calculate month-over-month growth per customer, and see a running total of total MRR.

The Brief

Write three SQL queries using window functions. Assume a table `monthly_mrr` with columns: `customer_id`, `month`, `mrr_amount`.

Deliverables

  • Query 1: Rank customers by their latest month MRR using ROW_NUMBER or RANK, partitioned by month
  • Query 2: Calculate month-over-month MRR change per customer using LAG
  • Query 3: A running total of company-wide MRR ordered by month

Submission Guidance

Explain the difference between ROW_NUMBER, RANK, and DENSE_RANK in one sentence each.

Submit Your Work

Your submission is graded against the rubric on the right. If you pass, you get a public Badge URL you can share on LinkedIn. There is no draft save, so work offline first and paste your finished response here.

This appears on your public Badge.

0/20000 charactersMarkdown supported

One per line or comma separated. Up to 5 links.

By submitting, you agree your submission text, name, and evaluation will appear on a public Badge URL.