0
✦ Zero setup • Real SaaS schemas • Instant diff grading

Master SQL by solving real business problems.

Stop watching tutorials. Write queries against Stripe revenue, cohort retention, and user attribution tables with instant sub-5ms feedback.

Sub-5ms query runtimeReal B2B & Fintech tables100% private in-browser execution
Query Engine • 3.2ms
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
WITH monthly_revenue AS (
SELECT
DATE_TRUNC('month', invoice_date)::date AS billing_month,
SUM(amount) AS mrr,
LAG(SUM(amount)) OVER (
ORDER BY DATE_TRUNC('month', invoice_date)
) AS prev_mrr
FROM saas_invoices
WHERE status = 'paid'
GROUP BY 1
)
SELECT
billing_month, mrr,
ROUND(((mrr - prev_mrr) / prev_mrr) * 100, 1) AS mom_growth_pct
FROM monthly_revenue;
Correct: 100% Match
3 rows • 3.2ms
billing_monthmrrmom_growth_pct
2024-03-01$68,900+27.1%
2024-02-01$54,200+27.5%
2024-01-01$42,500null

Checks row counts, columns, and data values against reference benchmarks.

Schema: b2b_saasTry it in the IDE

How it works

A tight feedback loop designed for learning SQL by writing queries, not watching slides.

01

Jump into real data

Tackle realistic B2B SaaS MRR, e-commerce checkouts, and customer churn tables—not toy bookstore databases.

02

Write in a real engine

Execute queries locally with full PostgreSQL power, rich keyboard shortcuts, and sub-5ms runtime.

03

Instant row-by-row grading

Get automated visual diffs on row counts, column types, and data values. Learn from mistakes instantly without guessing.

Real-World Guided Investigations

Solve End-to-End Projects

Move beyond isolated syntax drills. Connect queries into cohesive business investigations to build portfolio-grade analytical skills.

Curriculum

76 structured problems organized into 6 tracks. Start with simple filters or jump straight to window functions.

0 / 76 solved

Master core SQL filters, multi-column ordering, pattern matching, and CASE WHEN logic.

0 / 12

A table with subscription_id, company_name, plan_tier, and mrr sorted by highest MRR first.

Start

Unique list of acquisition_channel and country_code with no null or unknown values, alphabetically sorted.

Start

List of waiting emergency patients under Resuscitation or Emergent triage, sorted chronologically.

Start

Express delivery orders >= $250 still pending or processing, sorted by price descending.

Start

High-performing engineers earning under $160k, sorted by rating descending and salary ascending.

High-risk non-US wire transfers between $10k and $50k, sorted by highest risk score first.

Online top-rated XL and Black tier drivers eligible for surge dispatch.

Paid tier accounts missing payment provider credentials, sorted by creation date.

Budget wireless and Bluetooth audio products sorted by price ascending.

Customer profiles with computed loyalty tier labels sorted by lifetime spend.

Inpatients in clinical distress requiring ICU escalation, sorted by lowest oxygen saturation.

Dispute tickets classified by escalation priority and sorted by disputed amount.

SaaS metrics, GMV, chargeback ratios, fleet SLA adherence, and grouped HAVING filters.

0 / 12

Aggregate table showing tier, total_mrr, active_customers, and avg_seats for tiers with >= 2 active accounts.

Start

Summary table of category, total_orders, total_gmv, and refund_rate_pct sorted by highest refund rate first.

Start

Summary of department_name, total_admissions, avg_stay_days, and max_stay_days for wards with >= 2 admissions.

Start

High-risk merchants with dispute rate >= 1.0%, sorted by highest dispute rate.

Delivery metrics per zone showing total packages, average transit time, and on-time percentage.

Department compensation metrics including min, max, avg, and wage spread, sorted by spread descending.

Plan tiers showing total events, unique active workspaces, and events per workspace.

Summary of promo code sales metrics with net revenue >= $500, sorted by highest net revenue.

Summary of pharmaceutical spending per drug category sorted by total cost.

High-volume ATMs requiring priority cash restocking, sorted by cash dispensed.

Summary of ride requests, completed rides, and completion percentage per vehicle tier.

Summary of lost MRR and churned accounts per industry sector with lost MRR >= $3,000.

Relational data modeling, dormant account detection, multi-table joins, and FULL OUTER reconciliations.

0 / 12

List of customer_id, company_name, account_manager, and plan_name for customers with zero activity records.

Start

Campaign performance metrics with campaign_name, channel, budget_spent, revenue_generated, and roas.

Start

Roster of admitted inpatients with attending physician details, sorted by ward room.

Start

List of unreceived purchase orders sorted chronologically by expected delivery date.

Org chart hierarchy showing employee name, title, and manager name.

Compliance violation list of high-value wires sent to unverified accounts.

Trips performed with uninspected vehicles sorted by fare amount.

Complete plan-to-feature matrix with enabled status flag.

Flagged prescriptions where prescribed drug substance matches documented patient allergies.

Reconciliation table classifying each transaction as Matched, Missing in Bank, or Missing in Ledger.

High-value abandoned cart sessions with cart value >= $100.

Two-leg transit routes from Chicago with layover hub and total flight hours.

MoM revenue acceleration, regional rankings, running totals, moving averages, and NTILE quartiles.

0 / 14

Time-series table showing month_date, revenue, prev_month_revenue, and growth_pct.

Start

Filtered table with rep_name, region, total_bookings, and regional_rank containing only rank 1 and 2 reps per region.

Start

Time-series showing entry_date, daily_net, and running_balance.

Start

User login history with next session date and gap in days.

Daily sales alongside 3-day rolling window average.

Patient telemetry readings showing previous heart rate and BPM delta.

Transaction log showing the incremental card usage sequence number.

Drivers segmented into 4 earnings quartiles (1 = top 25%, 4 = bottom 25%).

Employee salary percentile within department on a 0.00 to 1.00 scale.

Monthly expansion MRR alongside cumulative cohort expansion total.

Order history showing order amount alongside the customer first purchase value.

ER patients categorized into 4 wait time quartiles.

Ledger lines showing running balance per account.

Trip log showing preceding dropoff timestamp per driver.

Modular enterprise pipelines, logo churn rates, repeat purchase cohorts, and Recursive CTE hierarchies.

0 / 12

Single row summary with total_accounts, churned_accounts, and churn_rate_pct.

Start

Single row summary showing new_mrr, expansion_mrr, contraction_mrr, and net_new_mrr.

Start

Summary with total_customers, repeat_customers, and repeat_rate_pct within 30 days.

Start

Single row summary showing total discharges, readmissions within 30 days, and readmission rate percentage.

Summary of client count and total assets grouped by wealth tier.

Employee hierarchy showing reporting depth distance from the executive level.

Summary of stops, total driving time, and shift violation status per route.

Power users utilizing at least 3 distinct modules and logging >= 10 actions.

Customer lifetime spend with quartile segmentation.

Surgical rooms with total surgery minutes and utilization percentage.

Monthly paydown schedule showing remaining loan balance after 4 periods.

At-risk inventory items with 10 or fewer days of remaining stock.

Cohort retention matrices, JSONB audit telemetry, RFM segmentation, and AML structuring forensics.

0 / 14

Extracted telemetry metrics with log_id, feature_name, duration_ms, and status for vector_search_v2 successes.

Start

Cohort table displaying cohort_month, activity_month, and active_users.

Start

Flagged wire transfers matching sanctioned names on official watchlists.

Start

Extracted service error metrics for all fatal incidents.

Customer profiles with Recency, Frequency, and Monetary metrics.

Conversion funnel counts and admission rate percentage from the emergency department.

Vehicles overdue for preventative maintenance sorted by overdue miles.

Departmental turnover rates and resignation counts.

Executable arbitrage pairs where Exchange A bid exceeds Exchange B ask.

Single row summary showing DAU, MAU, and stickiness percentage.

Purchase funnel step counts and overall conversion percentage.

Summary of pathogen isolates and susceptibility percentage.

Geographic dispatch zones with calculated surge pricing multipliers.

Suspected smurfing bank accounts with 2 or more sub-$10k deposits.

What you'll practice

The SQL features most commonly used in real jobs and interview technical screens.

01

Window Functions

LAG, LEAD, DENSE_RANK, running sums, and partitioned rankings.

02

CTEs & Subqueries

Common Table Expressions, multi-step queries, and modular pipeline design.

03

Relational Joins

INNER, LEFT, FULL OUTER, anti-joins, and multi-table joins.

04

Aggregations & HAVING

GROUP BY, HAVING filters, conditional sums, and distinct counts.

05

PostgreSQL JSONB

Extracting JSON objects, array filtering, and semi-structured querying.

06

Business Analytics

Cohort retention, marketing attribution, churn risk, and MRR expansion.

Who it's for

Designed for practical querying skills, not puzzle trivia.

Data Analysts & Analytics Engineers

Practice window functions and multi-table CTEs to prepare for technical screens and daily analytics jobs.

Software & Backend Engineers

Learn modern PostgreSQL analytical queries and JSONB extraction without setting up local database instances.

Product Managers & Operations

Gain the ability to query retention models and validate product metrics independently.

Frequently asked questions

Common questions about in-browser execution, supported features, and pricing.

Unlike algorithmic puzzle sites or basic syntax cheatsheets, DB Exercises focuses entirely on real-world business analytics. You write queries on realistic SaaS customer tables, cohort retention models, multi-touch ad attribution, and e-commerce GMV datasets. Furthermore, execution is 100% in-browser via WebAssembly, so queries evaluate in milliseconds with zero server queue lag.

Start practicing now

No registration required. 18 comprehensive starter problems are completely free.