Large orders with customer names

joins

Large orders with customer names

Amazon SQL Interview Question

Amazon Business account managers call customers personally after any very large order, so they need the customer's name next to each one.

List every order worth more than 3000, with the order_id, the name of the customer who placed it as customer_name, and the amount.

Asked of

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

ordersTable35 rows

Column NameType
order_idBIGINT
customer_idBIGINT
order_dateDATE
statusVARCHAR
amountDOUBLE

customersTable10 rows

Column NameType
customer_idBIGINT
nameVARCHAR
countryVARCHAR
segmentVARCHAR
signup_dateDATE

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

customersExample Input

customer_idnamecountrysegmentsignup_date
1Priya SharmaIndiaconsumer2023-01-14
2Marcus WebbUnited Statesenterprise2023-02-03
3Ana SousaBrazilconsumer2023-02-27
4Liam O'ConnorIrelandsmall_business2023-03-15
5Yuki TanakaJapanenterprise2023-04-02
6Fatima Al-RashidUnited Arab Emiratesconsumer2023-05-21
7Daniel OkaforNigeriasmall_business2023-06-08

Example Output

order_idcustomer_nameamount
1007Yuki Tanaka3200

Explanation

Order 1007, worth 3,200, is the only order in the example above 3,000. It was placed by customer 5, Yuki Tanaka, so that name appears next to it.

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