How can we calculate total completed spending for every customer?
Filtering completed orders and aggregating by customer_id measures Customer Lifetime Value (CLV).
CLV reporting, marketing ROI attribution, customer cohort valuation.
SELECT
customer_id,
SUM(amount) AS lifetime_value
FROM orders
WHERE status = 'Completed'
GROUP BY customer_id;Practice typing production-grade SQL code for Customer Lifetime Value.