News to Denver
- O(n log n) · Hard
- Full plan
- SQL
- subqueries
- joins
Problem
The store is mailing a flyer to Denver, and the owner doesn't want to fill it with things Denver already knows. The flyer is for what's new there: the products no Denver customer has ever ordered. A product nobody has ordered, in any city, is new to Denver too.
Every order counts, including the one dated the 20th: mistyped date or not, whoever placed it already knows the product.
Show two columns for those products, the name and then the price.
What it has to return
These rows, in any order
| name | price |
|---|---|
| Laptop | 899 |
| Tablet | 320 |
| Headphones | 59.9 |
| Speaker | 74 |
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 p.name, p.price
FROM products p
JOIN orders o
ON o.product_id = p.id;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 log n) challenges
- Not on the rosterSQL · subqueries · joins · grouping
- Often ordered togetherSQL · joins · grouping
- One student, one voteSQL · subqueries · grouping
- Report cards read acrossSQL · joins · grouping · conditionals
- Spent nothing, still on the listSQL · joins · nulls · grouping
- The easy gradersSQL · subqueries · sets · joins