Price category without CASE or IF (Yandex Praktikum)
A Yandex Praktikum trainer module runs a mini-project on a stationery store. Students receive an order catalog and must tell which price tier each item belongs to. The constraint: no CASE, no IF — the category must come from a range JOIN.
Three tables:
- orders(order_id, last_name, product, ordered_at) — ordered_at TIMESTAMPTZ
- prices(product, price) — price NUMERIC(15,2)
- categories(category, price_range) — category VARCHAR(20), price_range NUMRANGE with bounds [limit_1, limit_2)
For each order, pull the item's price and the category whose price_range contains it. Remember: no CASE, no IF — JOIN only.
Expected output sample
This is what a correct answer looks like — its row count is its own, it doesn't have to match the schema tables.
| price | product | category | last_name |
|---|---|---|---|
| 120.00 | Notebook | cheap | Ivanova |
| 15.00 | Pen | cheap | Petrov |
| 3500.00 | Backpack | medium | Sokolova |
Sign in to see submission history
Sign inSign in to use AI Mentor
Sign in