SQL Query: Calculate Customer Lifetime Value (LTV)
SELECT customer_id, SUM(order_amount) AS total_revenue, COUNT(order_id) AS total_orders, SUM(order_amount) / COUNT(order_id) AS average_order_value FROM orders GROUP BY customer_id
Calculating Customer Lifetime Value (LTV) is critical for understanding your business profitability. This SQL query works by grouping your transaction data by customer ID and aggregating their total spend against their total order count to derive a personalized Average Order Value (AOV).
By running this query on your orders table, you can quickly identify your high-value segments and adjust your marketing strategy accordingly. Whether you are using PostgreSQL, MySQL, or SQL Server, this snippet provides the foundation for accurate financial reporting and customer segmentation.