Loading exercise…
Loading exercise…
Exercises are built for a keyboard. Read the task here, then open this page on a laptop to solve it.
Several steps in one WITH. One WITH can hold several named steps, separated by commas, and each step can use the ones before it. When two tables have different grains (one row per region here, one per region and month there), bring each to the same grain in its own step before you join them. Otherwise the join repeats rows and every SUM after it grows.
with per_category as ( select category, count(*) as products from products group by category ), biggest as ( select max(products) as most from per_category ) select pc.category, pc.products from per_category pc join biggest b on pc.products = b.most
You asked the AI assistant for 2025 revenue against target per region. It reports every region at more than eight times its annual target, which nobody believes.
AI assistant: “I built a CTE with completed revenue per region and joined it to the targets table to compare against the yearly target.”
Run the AI query, then fix it so it returns region, revenue (completed, 2 decimals), target (the full-year sum of revenue_target) and pct_of_target (revenue as a percent of target, 2 decimals).
Loading the Brightline dataset…
Language
Full plan
SQL ✓ · Excel and Power BI also included
Cancel anytime · 14-day full refund · Secure payment by Stripe