SQL QuestSQL Interview Questions › Conditional Logic

Order Funnel Conversion

HardProQuerying BasicsConditional LogicAggregation & Grouping

Build an order status funnel. Show the total count of orders at each stage: total_orders, confirmed (status = 'Confirmed' or 'Shipped' or 'Delivered'), shipped (status = 'Shipped' or 'Delivered'), and delivered (status = 'Delivered'). Also show confirm_rate, ship_rate, and deliver_rate as percentages of total, rounded to 1 decimal. This funnel analysis pattern is the bread and butter of product analytics at every FAANG company.

Solve it in the browser editor →

Runs on SQLite in your browser, graded against the expected result, no signup. A wrong answer gets a diagnosis, not just "incorrect".

Schema

orders

order_idcustomer_idproductcategoryquantitypricetotalorder_datecountrystatus
11Laptop ProElectronics11299.991299.992024-01-15USAcompleted
22Wireless MouseElectronics249.9999.982024-01-16Canadacompleted
33Office ChairFurniture1349.99349.992024-01-17USAcompleted

Expected output: confirm_rate: 80.0, ship_rate: 60.0, deliver_rate: 45.0

Hint

This is a Pro challenge — the hint, the step-by-step tutor and the reference solution open in the app.

Concepts

SELECT CASE Aggregation Conditional Aggregation

Practise the topic: SQL practice questions · CASE WHEN practice · GROUP BY exercises · Advanced SQL interview questions

In these company practice sets

Airbnb · Amazon · Ramp · Revolut · Shopify · Snowflake · Stripe · TikTok · Microsoft

A SQL Quest challenge matched to patterns reported for these companies — not a question any of them has published.

Related questions

Order Sessionization by CustomerHard · ProSelf-Join: Manager Salary ComparisonHard · ProCustomer Lifetime Value PipelineHard · ProIsland Length ClassificationHard · ProDepartment Salary Percentile BucketsHard · ProFailure Rate by Torque BucketHard · Pro

Where would this cost you points in an interview?

Ten questions, no signup: a Skillmap across nine SQL skills and the one to fix first.

Take the readiness test