Kotomarket showcase: price tiers and the top 5

Kotomarket showcase: price tiers and the top 5

The "Kotomarket" marketplace catalog has a flat products table of cat goods: id, name, category, price (rubles), in_stock (units on hand). The marketing team is building a "Best deals" showcase and asks you to assemble it with a single SELECT query. Showcase requirements: 1. Price tier. Every product gets a price_tier column: products cheaper than 500 ₽ — 'бюджет', from 500 ₽ up to (not including) 1500 ₽ — 'средний', 1500 ₽ and above — 'премиум'. 2. Product selection. Only products that are in stock make the showcase. Of those, marketing wants the ones in the «корм» or «игрушки» category, plus — regardless of category — anything cheaper than 500 ₽. 3. Order. Most expensive first; products with equal prices are ordered by name alphabetically. 4. Size. The showcase holds only the first 5 rows of the selection. Output the columns in this order: name, category, price, price_tier. Row order matters (it is defined by the sort).

Exemplo de resposta esperada

É assim que se parece uma resposta correta: ela tem seu próprio número de linhas e não precisa coincidir com as tabelas do esquema. Sua resposta precisa retornar os mesmos nomes de colunas do exemplo: use AS para renomeá-las se for preciso.

namecategorypriceprice_tier
Туннель «Норка»игрушки990средний
Корм «Сытый кот» 2кгкорм890средний
Сухой корм «Океан» 1кгкорм640средний
PostgreSQLv16
Entre para enviar

O resultado da sua consulta aparecerá aqui

Focus radio
Paused · SomaFM · Fluid