Menu
CoddyTech

Prioritize the Shortlist

Part of the First Queries section of Coddy's PostgreSQL journey. Lesson 18 of 20.

challenge icon

Challenge

Medium

Keep the below-25 price and positive-stock filters and all four columns from the previous step. Add priority: low when stock is below 4, otherwise normal. Change the sort to inventory_value descending, then id ascending.

The input tables are shown in the test panel. Each run starts from fresh data. Return the named columns in the stated order; do not hard-code the displayed rows.

Try it yourself

SELECT id, name, price, price * stock AS inventory_value FROM products WHERE price < 25 AND stock > 0 ORDER BY price, id;

All lessons in First Queries

Practice on your own: PostgreSQL playground