Weekly SQL challenge

One problem a week, one leaderboard

Write the query, run it in your browser against the practice warehouse, and submit. Your SQL never leaves the page: only a fingerprint of the result is checked. The board ranks this week's solvers by how soon after Monday 00:00 UTC they got it right.

Week 2026-W45Next problem in a few days

This week's problem

Customer lifetime summary

Build the customer dimension the CRM team keeps asking for: order count, completed revenue, and first and last order timestamps. Customers with no orders must still appear, with zero revenue rather than NULL.

Requirements

  • Columns: customer_id, name, orders, completed_revenue, first_order_at, last_order_at
  • Every customer appears, even with no orders
  • orders counts order rows; completed_revenue only sums completed orders and is 0 when there are none
  • Order by completed_revenue descending, then customer_id

Expected columns: customer_id, name, orders, completed_revenue, first_order_at, last_order_at. Row order is not scored.

Tables

customers

~12 rows

Customer dimension. Every customer has at least one order in this seed.

  • customer_idTEXTprimary key
  • nameTEXT
  • countryTEXT
  • signup_dateTEXTYYYY-MM-DD

orders

~200 rows

Order headers. One row per order, so amount is the order total — not a line total.

  • order_idINTEGER1000–1199
  • customer_idTEXTC01–C12
  • countryTEXTUS, DE, IN, UK, BR
  • amountREAL
  • statusTEXT'completed' or 'cancelled'
  • ordered_atTEXTYYYY-MM-DD HH:MM:SS

Want more practice? This problem also lives in theproblem setwith hints and the reference solution.

Loading SQL engine…

Checking your sign-in…

Output

Run your query to see the result set.

Leaderboard

Top 20 this week, by time from Monday 00:00 UTC to the first correct answer.

Loading the leaderboard…

How the weekly challenge works

A new problem is picked every Monday at 00:00 UTC from the free problem set, and no problem repeats until every one has had its week. Queries run in SQLite inside your browser on the same practice data as theSQL sandbox. When you submit, the page hashes your result (column count and sorted rows, numbers rounded to six decimals) and the server compares that hash with the reference answer's. Your name on the board is your first name and last initial; untick the box to appear as Anonymous.

Search DataLane

↑↓ navigatealt ↑↓ jump group↵ openesc close