Menu
mediumMaybank · joinsBasic

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

customers
idINT
nameTEXT
transactions
idINT
customer_idINT
amountNUMERIC(10,2)

Basic

The example input, expected output, and walkthrough for this question unlock with a Basic plan.

↑ Read the question

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.

See Basic plans

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 plans

RM 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 plans

RM 25/mo · cancel anytime

Keep going

Company names are trademarks of their respective owners, used here only to describe practice material. mahir_data is not affiliated with, endorsed by, or sponsored by any company named on this site. Terms.