Orders Using Apple Pay
Which orders were paid using Apple Pay, and who made them?
- Joins
- Date analysis
- Filtering
- Sorting
Challenge brief
Understand the request
Apple Pay Analytics wants to measure Apple Pay adoption by reviewing all orders completed via the platform.
List all Apple Pay orders with order ID, customer full name, order date, and total amount.
Return
- order_id
- customer_name (first + last)
- order_date
- total_amount
Constraints
- Return orders paid with Apple Pay
- Show the newest orders first and resolve timestamp ties by order ID
Data you will use
Review the relevant tables before deciding how to join, filter, or aggregate them.
orders
order_idINTEGERcustomer_idINTEGERorder_dateDATETIMEtotal_amountREALpayment_methodVARCHAR(50)
customers
customer_idINTEGERfirst_nameVARCHAR(50)last_nameVARCHAR(50)
Hints, when you need them
Open one clue at a time so you still do the reasoning.
Hint 1
Orders are in orders, customer names are in customers. Join on customer_id. Filter payment_method to 'Apple Pay'.
Hint 2
INNER JOIN orders to customers on customer_id. WHERE o.payment_method = 'Apple Pay'. Concatenate name. ORDER BY o.order_date DESC.
Hint 3
Build question 4 from its business grain: identify the driving rows, add only valid relationships, then apply the required filtering, aggregation, and deterministic ordering.
Verified SQL answer
Attempt the problem first, then compare structure and reasoning—not just syntax.
Reveal solution and explanation
SELECT o.order_id, c.first_name || ' ' || c.last_name AS customer_name, o.order_date, o.total_amount FROM orders o INNER JOIN customers c ON o.customer_id = c.customer_id WHERE o.payment_method = 'Apple Pay' ORDER BY o.order_date DESC, o.order_id DESC;Why this works
5 of 10 orders used Apple Pay. The other 5 used Credit Card or Debit Card. Alice Johnson is the most frequent Apple Pay user with 3 transactions.
Success check
5 Apple Pay orders — Alice Johnson used Apple Pay for 3 of them
Expected result
Use this output to verify values, aliases, ordering, and row count.
| order_id | customer_name | order_date | total_amount |
|---|---|---|---|
| 2009 | Alice Johnson | 2024-02-08 12:00:00 | 2499 |
| 2007 | Emma Davis | 2024-02-03 10:20:00 | 799 |
| 2005 | David Brown | 2024-01-25 11:00:00 | 399 |
| 2003 | Alice Johnson | 2024-01-20 09:15:00 | 249 |
| 2001 | Alice Johnson | 2024-01-15 10:30:00 | 999 |
Learn the concepts behind this answer
Strengthen your understanding with these targeted learning topics:
Continue practicing
Explore related company challenges
Microsoft
Independent Microsoft-style cloud, productivity, subscription, usage, support, and customer analytics SQL practice.
Google
Independent Google-style search, advertising, user-engagement, and video-product SQL practice.
Amazon
Independent Amazon-style e-commerce, warehouse, inventory, and customer analytics SQL practice.
Return to the complete interview preparation experience.