Skip to the content

The 250 Club

Problem

The store is starting a club for its best customers. You're in once your orders add up to more than 250, where each order counts for its product's price times the units ordered. One big order or several small ones, it makes no difference, and exactly 250 doesn't get you in yet.

The membership card has the customer number on it. Show the customer_id and then that customer's total, rounded to 2 decimals. The order dated the 20th has the day mistyped, but the order was placed: its money counts.

What it has to return

These rows, in any order

customer_idtotal
1299.9
2797.5
6958.9

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.customer_id, p.price
FROM orders o
JOIN products p
  ON o.product_id = p.id
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 →