Active products

filtering

Active products

Target SQL Interview Question

Target is refreshing the product list on the Target.com homepage. Only products that are currently for sale should appear there.

List the product_id and product_name of every product that is currently active.

Asked of

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

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_idproduct_name
1Wireless Mouse
2Mechanical Keyboard Pro
3Noise Canceling Headphones
4Standing Desk
5Ergonomic Chair Pro
6Desk Lamp
7USB-C Hub

Explanation

Seven of the eight products in the example are active, so all seven appear in the output. The Notebook Set is no longer active, so it is left out.

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