For data analyst & data scientist interviews

Practise SQL interview questions on realistic data

Try one now: edit the query and press Run & check. It runs in your browser, no signup.

easyfree, no signup

Revenue by Product Category

Finance wants a quick view of which product categories bring in the most money. Calculate total revenue per category, counting only completed orders. Line revenue is quantity times unit_price.

Expected output: category, revenue (rounded to 2 decimals). Highest revenue first.

customers(customer_id, name, country, signup_date, referred_by)

products(product_id, name, category, price)

orders(order_id, customer_id, order_date, status)

order_items(order_id, product_id, quantity, unit_price)

Open the full problem page with column notes
SQLite · runs in your browser
Ctrl/⌘ + Enter to run
Expected output preview (5 rows, order matters)
categoryrevenue
Electronics8311.74
Home6169.04
Apparel4783.72

Showing 3 of 5 rows.

Hints

Worked solution

Run at least one query to unlock it.
Browse all 70 problems

70 original problems on window functions, retention cohorts, funnels, self-joins and attribution. 24 easy · 30 medium · 16 hard · 12 free without an account

Runs in your browser

A real SQLite engine runs on your device. No setup and no waiting for a server.

Instant answer checks

Your result is compared with the expected output. Row order is ignored unless the question asks for it.

Explanations that teach

Every problem has progressive hints and a worked solution explaining the pattern and the common traps.

Four realistic datasets

E-commerce store

An online store selling electronics, home goods, books, apparel and beauty products to customers in six countries (Jan 2025 to Mar 2026).

customers · products · orders · order_items

Ride-share marketplace

Trip requests in four US cities from January to March 2026, with drivers, riders, fares and ratings.

drivers · riders · trips

B2B SaaS product events

A project-management SaaS: company accounts, their users, product event logs (Jan to Apr 2026) and subscription history.

accounts · users · events · subscriptions

Digital ads performance

A retailer's paid campaigns across search, social, display and video in February 2026: daily delivery, individual ad clicks and purchases.

campaigns · ad_daily · ad_clicks · conversions

Practise by topic

Start with the free problems

No account needed. Sign up free to unlock the rest and save your progress.