Practice · medium · dataset: ecom
Product price bands
Bucket products into four price bands: under-150 for prices below 150, 150-299 for prices from
150 up to but not including 300, 300-399 for prices from 300 up to but not including 400, and
400-plus for prices of 400 and above.
For each band that contains at least one product, report band, product_count, and average price
rounded to two decimals as avg_price. Sort by band ascending.
Tables available
| Table | Columns |
|---|---|
products |
product_id, name, category, unit_price |
The band boundaries are half-open: 300 belongs to 300-399, not 150-299.
⌘/Ctrl + Enter to grade
Write a query, then grade it.
Hints
Try it first. Reveal a hint only when you are stuck.