Return
full_name — customer's nameemail — customer's emailmerchant_name — merchant's name (with highest total spend for this customer)total_spent — total transaction value at that merchant (for that customer)full_name ascending.Expected output
| full_name | merchant_name | total_spent | |
|---|---|---|---|
| Arjun Patel | arjun.patel@example.com | BestBuy | 6490 |
| Emma Wilson | emma.wilson@example.com | KL Duty Free | 780 |
| Liam Nguyen | liam.nguyen@example.com | BestBuy | 899 |
First 3 of 7 rows your query should return. Your column aliases don't need to match.
customers
| customer_id | full_name | home_city | home_country | segment | |
|---|---|---|---|---|---|
| 1 | Olivia Brooks | olivia.brooks@example.com | New York | US | premier |
| 2 | Liam Nguyen | liam.nguyen@example.com | San Francisco | US | retail |
| 3 | Sofia Rossi | sofia.rossi@example.com | Milan | IT | premier |
| 4 | Arjun Patel | arjun.patel@example.com | Mumbai | IN | retail |
| 5 | Emma Wilson | emma.wilson@example.com | London | GB | premier |
accounts
| account_id | customer_id | account_number | account_type | currency | opened_on | status |
|---|---|---|---|---|---|---|
| 1 | 1 | US-4001-2211 | checking | USD | 2019-05-11 | active |
| 2 | 2 | US-4001-8842 | credit | USD | 2020-02-03 | active |
| 3 | 3 | IT-2205-7781 | credit | EUR | 2018-11-20 | active |
| 4 | 4 | IN-3309-1120 | checking | INR | 2021-07-15 | active |
| 5 | 5 | GB-1180-5567 | credit | GBP | 2017-03-30 | active |
cards
| card_id | account_id | last4 | network | issued_on | status |
|---|---|---|---|---|---|
| 1 | 1 | 4417 | visa | 2022-05-20 | active |
| 2 | 2 | 5590 | mastercard | 2021-02-10 | active |
| 3 | 3 | 3701 | amex | 2020-01-05 | active |
| 4 | 4 | 4460 | visa | 2023-01-18 | active |
| 5 | 5 | 5512 | mastercard | 2022-08-01 | active |
merchants
| merchant_id | name | mcc | category | city | country |
|---|---|---|---|---|---|
| 1 | Whole Foods Market | 5411 | grocery | New York | US |
| 2 | MTA Subway | 4111 | transport | New York | US |
| 3 | Netflix | 4899 | subscription | Los Gatos | US |
| 4 | Chase ATM | 6011 | atm | New York | US |
| 5 | BestBuy | 5732 | electronics | San Francisco | US |
transactions
| transaction_id | card_id | merchant_id | txn_at | amount | currency | txn_city | txn_country | latitude | longitude | channel | status |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 1 | 1 | 2024-03-02 09:14:00 | 42.3 | USD | New York | US | 40.7128 | -74.006 | chip | approved |
| 2 | 1 | 2 | 2024-03-02 18:02:00 | 2.75 | USD | New York | US | 40.7128 | -74.006 | contactless | approved |
| 3 | 1 | 3 | 2024-03-03 06:00:00 | 12.99 | USD | New York | US | 40.7128 | -74.006 | online | approved |
| 4 | 4 | 1 | 2024-03-03 13:00:00 | 8.2 | INR | Mumbai | IN | 19.076 | 72.8777 | chip | approved |
| 5 | 7 | 10 | 2024-03-04 12:30:00 | 16.2 | USD | New York | US | 40.7128 | -74.006 | chip | approved |
0 of 4 hints revealed
Submit an attempt first.