runtime
88 / 88

task Reconciliation & quality gates · hard

Capacity 5: project regional capacity at month end

Project every region’s capacity on April 30, 2026: sum capacity records valid on April 30 plus incremental deliveries arriving April 1 through April 30 inclusive. Exclude unmapped sites and include empty regions as zero. Assume deliveries remain available through the cutoff. Order by region id.

what to return

Columns
region_idprojected_units in this order
Rows
3 rows · in the order asked
Watch for
Every stage runs on a fresh database; earlier queries do not carry forward.
One unit is one compute unit. Snapshot date: 2026-04-01. Capacity intervals include valid_from and exclude valid_to; NULL valid_to means no end.
Future supply is incremental capacity, available on delivery_date. The snapshot excludes same-day deliveries, so projections add them once.
Skill
Produce reproducible capacity reports with explicit units, dates and grain. Refresher: Multi-grain joins without fan-out →

expected result

Your query should return exactly these columns and values. Run it and compare.

expected result3 rows · in this order
region_idprojected_units
1100
212
30

all 3 rows

data you can query

Sample rows from each table. Each column shows its type underneath; → marks a link to another table.

capacity_regions2 columns · 3 rows
idinteger · keynametext
1North
2South
3West

all 3 rows

capacity_sites3 columns · 4 rows
idinteger · keyregion_idinteger → capacity_regionsnametext
11Alder
21Birch
32Cedar
4NULLDrift

all 4 rows

current_capacity5 columns · 5 rows
idinteger · keysite_idinteger → capacity_sitesunitsintegervalid_fromtextvalid_totext
11402026-01-01NULL
22402026-01-01NULL
33992025-01-012026-04-01
4152026-05-01NULL
54102026-01-01NULL

all 5 rows

future_supply4 columns · 6 rows
idinteger · keysite_idinteger → capacity_sitesunitsintegerdelivery_datetext
1172026-04-10
2182026-04-10
31202026-05-01
4252026-04-30
53122026-04-01

showing 5 of 6 rows

solution.sql
 

Hints and the answer are always available. Using them counts the question as solved with help.