Skip to the content

The register, day by day

Problem

The owner wants to watch the money add up: how much came in on each day that had orders, and how much the store had taken in so far by the end of that day.

Today is January 15, 2026, and nobody orders in the future. An order dated after today is one of today's with the day mistyped, and its money goes with today's.

Show the day, that day's money, and the running total, in that order, with both amounts rounded to 2 decimals and the most recent day on top. You can write today as '2026-01-15' or as DATE('now').

What it has to return

These rows, in this order

dayday_totalrunning_total
2026-01-15499.72289.85
2026-01-148991790.15
2026-01-1235.65891.15
2026-01-11378855.5
2026-01-1045.5477.5
2026-01-0952.5432
2026-01-04288.5379.5
2026-01-039191

This is what comes out with the data in the practice database this challenge uses. The column names don’t count, so name yours however you like: what counts is how many there are and the order they come in. Besides this one, the challenge has hidden tests with other data that are revealed when you submit your solution.

You start with this

SQL

SELECT o.placed,
  SUM(p.price * o.quantity)
    AS money
FROM orders o
JOIN products p
  ON o.product_id = p.id
GROUP BY o.placed;
Solve this challenge

It opens in your browser, with the editor and the tests. This challenge is part of the full plan; the O(1) and O(log n) ones are free.

More O(n²) challenges

See all challenges →