Price bands

conditional logic

Price bands

Amazon SQL Interview Question

Amazon's pricing team groups products into price bands so shoppers can filter search results by budget.

Show the product_name, price and band as price_band for every product. The band is "Budget" for prices under 50, "Mid-range" for prices from 50 up to but not including 200, and "Premium" for prices of 200 or more.

Asked of

  • Data Analyst
  • Business Analyst
  • BI Analyst
  • Product Analyst
  • Analytics Engineer
  • Data Scientist

productsTable15 rows

Column NameType
product_idBIGINT
product_nameVARCHAR
categoryVARCHAR
brandVARCHAR
priceDOUBLE
discount_pctBIGINT
stock_quantityBIGINT
launch_dateDATE
is_activeBOOLEAN

productsExample Input

product_idproduct_namecategorybrandpricediscount_pctstock_quantitylaunch_dateis_active
1Wireless MouseElectronicsLogitech24.99101502023-02-14true
2Mechanical Keyboard ProElectronicsKeychron119NULL402023-05-01true
3Noise Canceling HeadphonesElectronicsSony299.991502022-11-20true
4Standing DeskFurnitureFlexispot349NULL122023-08-09true
5Ergonomic Chair ProFurnitureSteelcase1299552021-06-30true
6Desk LampFurnitureNULL39.5NULL802024-01-15true
7USB-C HubElectronicsAnker45202002023-03-22true
8Notebook SetStationeryMoleskine18NULL02022-09-01false

Example Output

product_namepriceprice_band
Desk Lamp39.5Budget
Ergonomic Chair Pro1299Premium
Mechanical Keyboard Pro119Mid-range
Noise Canceling Headphones299.99Premium
Notebook Set18Budget
Standing Desk349Premium
USB-C Hub45Budget
Wireless Mouse24.99Budget

Explanation

The Wireless Mouse costs 24.99, so it is Budget. The Mechanical Keyboard Pro costs 119, so it is Mid-range. The Standing Desk costs 349, so it is Premium.

The example above is a small slice of the data. Your query runs against the full tables.