Clearance candidates

logical operators

Clearance candidates

Target SQL Interview Question

At the end of each quarter, Target's operations team picks products for its clearance sale. A product is a clearance candidate if it is no longer active or if it has no stock left.

List the product_name of every clearance candidate. Each product should appear only once.

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
3Noise Canceling HeadphonesElectronicsSony299.991502022-11-20true
6Desk LampFurnitureNULL39.5NULL802024-01-15true
8Notebook SetStationeryMoleskine18NULL02022-09-01false
12Monitor ArmAccessoriesNULL892502022-12-12false
15WhiteboardStationeryQuartet65NULL182021-11-11false

Example Output

product_name
Monitor Arm
Noise Canceling Headphones
Notebook Set
Whiteboard

Explanation

The Noise Canceling Headphones are still active but have no stock, so they qualify. The Whiteboard still has 18 in stock but is no longer active, so it also qualifies. The Notebook Set and Monitor Arm meet both conditions and still appear only once each.

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