Menu
hardMaxis · joinsBasic

Total paid, joined across three tables

Maxis stores subscribers, plans, and payments in three separate tables. For each subscriber, return their name, their plan's name, and the total amount they've paid so far.

Subscribers who haven't made any payment yet should still appear, with a total of 0.

Return name, plan_name, and total_paid.

Schema

subscribers
idINT
nameTEXT
plan_idINT
plans
idINT
plan_nameTEXT
monthly_feeNUMERIC
payments
idINT
subscriber_idINT
amountNUMERIC

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

Billing wants a sanity check before the amounts: for each subscriber, how many payments have they made? Return name and payment_count — subscribers with none should show 0.

Solving follow-ups — the questions an interviewer actually asks next — unlocks with a Basic plan.

See Basic plans

RM 25/mo · cancel anytime

Now roll it up the other direction: for each plan, how much total revenue has it brought in across all its subscribers? Return plan_name and total_paid.

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.