Generate SQL Query to Calculate Monthly Recurring Revenue (MRR)
SELECT SUM(amount) AS mrr FROM subscriptions WHERE status = 'active' AND next_billing_date >= DATE_TRUNC('month', CURRENT_DATE) AND next_billing_date < DATE_TRUNC('month', CURRENT_DATE + INTERVAL '1 month');Calculating Monthly Recurring Revenue (MRR) is essential for SaaS businesses to track financial health. This query filters your subscriptions table for active users and sums their recurring payment amounts, scoped strictly to the current calendar month.
By using this logic, you avoid common pitfalls like counting cancelled subscriptions or including one-time purchases in your recurring revenue projections. Simply adjust the column names to match your database schema, and our AI will refine the query to fit your specific table structure.