← All SQL interview questions

Price spread across shelf categories

EasyAggregate FunctionsWalmartTarget

A category manager wants to see how wide the price range is in each aisle before planning a pricing review.

From shelf_prices, return for every category: item_count, min_price, max_price, avg_price (rounded to 2 decimals) and price_range (maximum minus minimum). Show the category with the widest range first and break ties alphabetically by category.

Sample data

Table: shelf_prices

14 row(s) · showing first 8

skuINTproduct_nameTEXTcategoryTEXTpriceNUMERIC(8,2)
1Full Cream Milk 1LDairy68.00
2Paneer 200gDairy95.00
3Greek YogurtDairy120.00
4Butter 500gDairy285.00
5Potato ChipsSnacks20.00
6Namkeen MixSnacks55.00
7Choco CookiesSnacks40.00
8Protein BarSnacks150.00

Practising alone only goes so far — our live cohorts pair SQL depth with dashboards, agentic analytics projects and mock interviews.

Explore the program