Total spend per customer
Maybank wants each customer's total card spend.
Join customers to transactions and return each customer's name and their total transaction amount as total_spent. Only include customers who have at least one transaction.
Schema
| id | INT |
| name | TEXT |
| id | INT |
| customer_id | INT |
| amount | NUMERIC(10,2) |
Basic
The example input, expected output, and walkthrough for this question unlock with a Basic plan.
Basic
The reference solution and walkthrough for this question unlock with a Basic plan.
Basic
This is a Basic question
Premium practice questions unlock with a Basic plan. The full solution, expected output, and grading are available to Basic members.
RM 25/mo · cancel anytime
The interviewer's next question
Maybank only wants repeat customers this time: return name and avg_spent (average transaction amount, rounded to 2 decimals) for customers with more than one transaction.
Solving follow-ups — the questions an interviewer actually asks next — unlocks with a Basic plan.
See Basic plansRM 25/mo · cancel anytime
Rank customers by total spend, highest first, and show the rank alongside the total. Return name, total_spent, spend_rank.
Solving follow-ups — the questions an interviewer actually asks next — unlocks with a Basic plan.
See Basic plansRM 25/mo · cancel anytime