Unfinished orders over 50

logical operators

Unfinished orders over 50

Target SQL Interview Question

Target's customer service team follows up on online orders that did not go through, but only when the order was worth more than 50.

List the order_id, status and amount of every order that did not complete and was worth more than 50.

Asked of

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

ordersTable35 rows

Column NameType
order_idBIGINT
customer_idBIGINT
order_dateDATE
statusVARCHAR
amountDOUBLE

ordersExample Input

order_idcustomer_idorder_datestatusamount
100112024-01-05completed120.5
100222024-01-07completed2400
100432024-01-15canceled45
100812024-02-02refunded75
101762024-03-08canceled62
102632024-04-13refunded88

Example Output

order_idstatusamount
1008refunded75
1017canceled62
1026refunded88

Explanation

Orders 1008, 1017 and 1026 were refunded or canceled, and each was worth more than 50. Order 1004 was also canceled, but it was worth only 45, so the team does not follow up on it.

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