SQL problem track
SQL Foundations
The eight-minute questions that open a screen: filtered aggregation, product joins, and the org-tree self-join.
5 problems · ~44 min total · Data Analyst · BI Analyst · Analytics Engineer · Data Engineer · Data Scientist
Step 1 · ~10 min · Stripe, Shopify, Square
Completed revenue by countryFinance wants revenue by country, but only for orders that actually completed. Cancelled orders must not contribute a cent. Return one row per country with revenue rounded to 2 decimals, biggest country first.
AggregationmediumProNot startedStep 2 · ~10 min · Amazon, Walmart, Instacart
Top products by units soldMerchandising wants units sold per product. The quantity lives on the line items, not the order header — summing orders.amount here is the classic wrong answer because an order can carry several products.
JoinsAggregationmediumProNot startedStep 3 · ~6 min · Google, Meta, Microsoft
Who reports to BenThe employees table is an org tree: manager_id points back at employee_id in the same table. Return Ben’s direct reports — one level down, not the whole subtree.
JoinsmediumProNot startedStep 4 · ~8 min · Instacart, DoorDash, Shopify
Orders with more than one lineMulti-line orders are the ones that break naive revenue joins, so find them first. Return every order carrying more than one line item, with its line count and total quantity.
AggregationeasyNot startedStep 5 · ~10 min · Meta, Snap, Pinterest
Event funnel by stageProduct wants funnel volume per stage: how many events fired and how many distinct customers reached each one. Total events overstates reach because one customer can fire the same event repeatedly.
AggregationmediumProNot started