All courses
Intermediate

Decision-ready business reports

Move beyond a correct query: define recurring revenue, measure activation, find unpaid balances, and reconcile billing mistakes before presenting a number.

6 exercises · 39 minutes · Data: SaaS company
Start course
SQL
01
→ 02
→ 03

Your exercises

01
Contracted MRR at September start

The board wants contracted MRR at the start of 1 September 2026, not cash collected. An account contributes its plan's monthly price if it was created on or before that date and had not churned by that date. Starter is €49, growth €199, scale €799. Return one column named mrr. Do not use invoices: open payments and double-billing should not change this metric.

6 min
02
Age open invoices for collections

On 30 September 2026, finance needs a collections list. For each invoice whose status is 'open', return company, invoice_date, amount, and whole days outstanding as of 2026-09-30. Sort by days outstanding highest first, then company A to Z.

5 min
03
Estimate duplicate invoice exposure

Billing found exact repeated paid invoices. For invoices dated in 2026 with status 'paid', define a repeated group as the same account_id, invoice_date and amount appearing more than once. Return one column named extra_paid_amount: the sum of amount for all copies beyond the first in each repeated group. This is a potential reconciliation amount, not automatically a refund.

7 min
04
Did new accounts create a report?

Product wants to review accounts created in 2026. An account is activated if it created at least one report from its signup date through the next 29 days. Return company, created_at and a text label 'activated' or 'not activated'. Sort by company A to Z.

7 min
05
Find live accounts with no recent usage

Customer success wants accounts that were still customers at the start of September 2026 but had no product event from 1 August through 30 September 2026. Return company, plan and sales_owner, sorted by company A to Z. This is a usage signal, not a churn prediction.

7 min
06
Compare September collections with MRR

Leadership sees two different September numbers and needs them side by side. Return one row with contracted_mrr at the start of 1 September 2026 (active accounts × plan price, as in the MRR exercise) and september_paid_invoices (sum of paid invoice amounts dated in September 2026). Do not force the two values to agree.

7 min
Queries run on sample company data in SQLite. Core SELECT, JOIN and GROUP BY patterns transfer to other SQL engines; functions, dates and types can differ.