Guide 9/9/2026

Generate SQL Query to Calculate Monthly Recurring Revenue (MRR)

#calculate mrr sql query#sql query for monthly recurring revenue#saas mrr sql calculation#generate sql for subscription revenue#subscription database mrr query
Quick Answer
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.

Ready to try it?

Use our SQL Query Generator to generate perfect results in seconds.

Open SQL Query Generator