Even-numbered orders

calculations

Even-numbered orders

Best Buy SQL Interview Question

Best Buy's quality team checks a sample of online orders by hand every month. To keep the sample simple and repeatable, the team checks every order whose ID is an even number.

List the order_id and amount of every order in the sample.

Asked of

  • Data 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
100312024-01-11completed89.99
100432024-01-15canceled45
100542024-01-18completed610.75
100622024-01-22completed1850.25
100752024-01-29completed3200
100812024-02-02refunded75
100962024-02-06completed55.4
101032024-02-09completed132.6

Example Output

order_idamount
10022400
100445
10061850.25
100875
1010132.6

Explanation

Of the ten orders in the example, 1002, 1004, 1006, 1008 and 1010 have even IDs, so those five are in the sample. The odd-numbered orders are left out, whatever their amount or status.

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