ISA-002 — Revenue Aggregation
🟢 Beginner
⏱ 15 Minutes
⭐ 10 Points
🔓 Free
💻 SQL | PySpark
🏢 Retail Analytics
Business Context
A retail company receives order-level transaction data from multiple stores.
Business stakeholders want a customer-level revenue report showing how much revenue each customer has generated.
The analytics team needs a summarized dataset that can be used for dashboards and KPI reporting.
Dataset
customer_orders
| order_id | customer_id | amount |
|---|---|---|
| O101 | 101 | 100 |
| O102 | 101 | 150 |
| O103 | 102 | 200 |
| O104 | 103 | 50 |
| O105 | 103 | 75 |
Task
Calculate the total revenue generated by each customer.
Return one record per customer.
Expected Output
expected_output
| customer_id | total_revenue |
|---|---|
| 101 | 250 |
| 102 | 200 |
| 103 | 125 |
Constraints
- Each customer may have multiple orders.
- Revenue is the sum of all order amounts for that customer.
- Final output should contain exactly one row per customer.
Supported Languages
✅ SQL
✅ PySpark
Hint
Aggregate the amount column at the customer level.
Solution
🔒 Premium Solution
Premium members receive:
- SQL Solution
- PySpark Solution
- Step-by-Step Explanation
- Optimization Discussion
Notebook Workspace
Cell 1Dataset: customer_orders
⏱ 15:00
Loading...
Run Results
✓ Workspace Ready
Rows Returned: --
Execution Time: --
Engine: Coming Soon
Execution Engine Coming Soon