Skip to main content

ISA-015 — Customer Lifetime Revenue

🟢 Beginner

⏱ 25 Minutes

⭐ 20 Points

🔓 Free

💻 SQL | PySpark

🏢 Retail Analytics

🎯 INNER JOIN

🎯 GROUP BY

🎯 SUM


Business Context

A retail company wants to understand the total revenue generated by each customer.

Management uses this information to:

  • Identify high-value customers
  • Design loyalty programs
  • Target premium customers
  • Improve customer retention

Customer information and order information are stored in separate datasets.

The analytics team must calculate lifetime revenue for every customer.


Business Impact

Customer Lifetime Revenue (CLV) is one of the most important business metrics.

It helps organizations:

  • Identify top customers
  • Improve retention strategies
  • Increase profitability
  • Prioritize marketing investments

Dataset

customers

customers
customer_idcustomer_name
101John
102Alice
103Bob

orders

orders
order_idcustomer_idamount
O001101500
O002101700
O003102300
O004103900
O005103100

Task

Calculate total revenue generated by each customer.

Return:

  • customer_name
  • lifetime_revenue

Expected Output

expected_output
customer_namelifetime_revenue
John1200
Alice300
Bob1000

Constraints

  • Join customers and orders using customer_id.
  • Aggregate revenue at customer level.
  • Return one row per customer.

Supported Languages

✅ SQL

✅ PySpark


Data Engineering Pattern

Customer KPI Aggregation Pattern

This pattern is commonly used for:

  • Customer dashboards
  • CRM systems
  • Loyalty programs
  • Revenue analytics

A customer dimension is combined with transaction facts to produce customer-level KPIs.


Concepts Tested

  • INNER JOIN
  • GROUP BY
  • SUM
  • Customer Analytics
  • Business KPIs

Hint

Combine customers and orders first.

Then aggregate revenue by customer.


Solution

🔒 Premium Solution

Premium members receive:

  • SQL Solution
  • PySpark Solution
  • Step-by-Step Explanation
  • KPI Walkthrough
  • Alternative Approaches

Notebook Workspace

Cell 1Dataset: customers
15:00
Loading...
Run Results
✓ Workspace Ready
Rows Returned: --
Execution Time: --
Engine: Coming Soon
Execution Engine Coming Soon