← All SQL interview questions
In-stock mid-range footwear and apparel
EasyWHERE & FilteringMyntraMeesho
A merchandising manager is building a festive-season landing page and only wants products that a shopper can actually buy right now.
From catalog_products, return product_id, product_name, brand and price for every product in the Footwear or Apparel category, priced between 1000 and 3000 (both inclusive), that currently has stock available. Show the most expensive products first and break ties by product_id.
Sample data
Table: catalog_products
14 row(s) · showing first 8
| product_idINT | product_nameTEXT | categoryTEXT | brandTEXT | priceNUMERIC(10,2) | stock_qtyINT |
|---|---|---|---|---|---|
| 1 | Aero Run Sneakers | Footwear | Stridewell | 2499.00 | 35 |
| 2 | Classic Loafers | Footwear | Stridewell | 3499.00 | 12 |
| 3 | Trail Sandals | Footwear | Wanderly | 1299.00 | 0 |
| 4 | Linen Shirt | Apparel | Weavecraft | 1799.00 | 50 |
| 5 | Denim Jacket | Apparel | Weavecraft | 3000.00 | 8 |
| 6 | Cotton Tee | Apparel | Loomhouse | 599.00 | 120 |
| 7 | Smart Watch | Electronics | Pulsar | 2999.00 | 20 |
| 8 | Canvas Sneakers | Footwear | Wanderly | 1000.00 | 44 |
catalog_products
- product_idINT
- product_nameTEXT
- categoryTEXT
- brandTEXT
- priceNUMERIC(10,2)
- stock_qtyINT
- Step 1: Filter the category with `IN ('Footwear', 'Apparel')` instead of chaining two `OR` conditions.
- Step 2: `BETWEEN` is inclusive on both ends, so products priced exactly 1000 and 3000 are kept.
- Step 3: `stock_qty > 0` removes sold-out items such as Trail Sandals and Formal Shoes.
- Step 4: Sort with `ORDER BY price DESC, product_id` so ties are deterministic.
SELECT product_id, product_name, brand, price
FROM catalog_products
WHERE category IN ('Footwear', 'Apparel')
AND price BETWEEN 1000 AND 3000
AND stock_qty > 0
ORDER BY price DESC, product_id;More WHERE & Filtering questions
Practising alone only goes so far — our live cohorts pair SQL depth with dashboards, agentic analytics projects and mock interviews.
Explore the program