Hardcoding a price cutoff is a bad idea - it goes stale every time Walmart's catalog team updates prices, so write a query that dynamically flags premium items by comparing against the catalog average. Using the products table, return id, name, and price for every product whose price is strictly above the catalogue average, ordered by price descending.
products
| column | type |
|---|---|
| id | INTEGER |
| name | TEXT |
| price | NUMERIC |
| category | TEXT |
| id | name | price | category |
|---|---|---|---|
| 1 | Widget | 10.00 | gadgets |
| 2 | Gadget | 25.00 | gadgets |
| 3 | Doohickey | 5.00 | tools |
| 4 | Thingamajig | 40.00 | tools |
| id | name | price |
|---|---|---|
| 4 | Thingamajig | 40.00 |
| 2 | Gadget | 25.00 |
The average price is (10 + 25 + 5 + 40) / 4 = 20.00. Widget (10.00) and Doohickey (5.00) are below the average; Gadget (25.00) and Thingamajig (40.00) are above it.