TGViewer
SQL Programming Resources SQL Programming Resources @sqlanalyst ยท 76.7K subscribers
Post #2660 1.55K
๐Ÿง  SQL Concepts You'll Practice

โœ” Joins

โœ” GROUP BY

โœ” HAVING

โœ” CASE WHEN

โœ” CTEs

โœ” Subqueries

โœ” Window Functions

โœ” LAG()

โœ” LEAD()

โœ” Date Functions

โœ” Conditional Aggregation

๐Ÿ“Š Business KPIs You Can Build

๐Ÿ“ˆ Monthly Recurring Revenue (MRR)

๐Ÿ“ˆ Annual Recurring Revenue (ARR)

๐Ÿ“ˆ Average Revenue Per User (ARPU)

๐Ÿ“ˆ Customer Lifetime Value (CLV)

๐Ÿ“ˆ Monthly Customer Churn Rate

๐Ÿ“ˆ Revenue Churn Rate

๐Ÿ“ˆ Customer Retention Rate

๐Ÿ“ˆ New Customers, New MRR

๐Ÿ“ˆ Expansion MRR, Contraction MRR, Churned MRR

๐Ÿ“ˆ Net Revenue Retention (NRR), Gross Revenue Retention (GRR)

๐Ÿ“ˆ Upgrade Rate, Downgrade Rate

๐Ÿ“ˆ Plan-wise Revenue, Active Subscriptions, Cancelled Subscriptions

๐Ÿ“ˆ Payment Success Rate, Failed Payment Rate

๐Ÿ“ˆ Monthly Revenue Growth, Revenue Contribution by Plan

๐Ÿ“ˆ Customer Segmentation

๐Ÿ’ก Example 1: Calculate MRR
SELECT
    SUM(p.monthly_price) AS mrr
FROM subscriptions s
JOIN plans p ON s.plan_id = p.plan_id
WHERE s.subscription_status = 'Active';

๐Ÿ’ก Example 2: Revenue by Plan
SELECT
    p.plan_name,
    COUNT(s.subscription_id) AS active_subscriptions,
    SUM(p.monthly_price) AS monthly_revenue
FROM subscriptions s
JOIN plans p ON s.plan_id = p.plan_id
WHERE s.subscription_status = 'Active'
GROUP BY p.plan_name
ORDER BY monthly_revenue DESC;

๐Ÿ’ก Example 3: Identify Churned Customers
SELECT
    customer_id,
    subscription_id,
    end_date
FROM subscriptions
WHERE subscription_status = 'Cancelled';

๐Ÿ’ก Example 4: Calculate Upgrade vs Downgrade Count
SELECT
    change_type,
    COUNT(*) AS total_changes
FROM subscription_changes
GROUP BY change_type;

๐Ÿ’ก Example 5: Calculate Average Revenue Per Customer
SELECT
    ROUND(SUM(p.monthly_price) / COUNT(DISTINCT s.customer_id), 2) AS arpu
FROM subscriptions s
JOIN plans p ON s.plan_id = p.plan_id
WHERE s.subscription_status = 'Active';

๐Ÿ’ก Example 6: Rank Customers by MRR
WITH customer_mrr AS (
    SELECT
        s.customer_id,
        SUM(p.monthly_price) AS mrr
    FROM subscriptions s
    JOIN plans p ON s.plan_id = p.plan_id
    WHERE s.subscription_status = 'Active'
    GROUP BY s.customer_id
)
SELECT
    customer_id,
    mrr,
    DENSE_RANK() OVER (ORDER BY mrr DESC) AS revenue_rank
FROM customer_mrr;

๐ŸŽฏ Key Insights You Can Derive

๐Ÿ”น Which subscription plan generates the most revenue?

๐Ÿ”น Which plan has the highest churn?

๐Ÿ”น How much MRR comes from new customers?

๐Ÿ”น How much revenue is lost through cancellations?

๐Ÿ”น Which customers have upgraded or downgraded?

๐Ÿ”น Is revenue growing month over month?

๐Ÿ”น Which customers contribute the most recurring revenue?

๐Ÿ’ผ This project is especially useful for Data Analysts, Product Analysts, Revenue Analysts, Growth Analysts, and Business Intelligence professionals working with SaaS and subscription-based businesses.

Double Tap โค๏ธ For More
  • โค 6
More from @sqlanalyst
  1. Oct 8, 2026๐ŸŽ“ ๐— ๐—ถ๐—ฐ๐—ฟ๐—ผ๐˜€๐—ผ๐—ณ๐˜ ๐—™๐—ฅ๐—˜๐—˜ ๐—–๐—ผ๐˜‚๐—ฟ๐˜€๐—ฒ๐˜€ ๐˜„๐—ถ๐˜๐—ต ๐—–๐—ฒ๐—ฟ๐˜๐—ถ๐—ณ๐—ถ๐—ฐ๐—ฎ๐˜๐—ฒ๐˜€! ๐Ÿš€๐Ÿ”ฅ Upgrโ€ฆ
  2. Oct 7, 2026๐Ÿš€๐—ฃ๐—ฎ๐˜† ๐—”๐—ณ๐˜๐—ฒ๐—ฟ ๐—ฃ๐—น๐—ฎ๐—ฐ๐—ฒ๐—บ๐—ฒ๐—ป๐˜ ๐—ง๐—ฟ๐—ฎ๐—ถ๐—ป๐—ถ๐—ป๐—ด | ๐—•๐—ฒ๐—ฐ๐—ผ๐—บ๐—ฒ ๐—ฎ ๐—™๐˜‚๐—น๐—น๐˜€๐˜๐—ฎ๐—ฐโ€ฆ
  3. Oct 7, 2026SQL Interview Series โ€” Part 4 ๐Ÿ“Œ Question 4: Find the Highest Salary in Each Department Suโ€ฆ
  4. Oct 7, 2026๐— ๐—ฎ๐˜€๐˜๐—ฒ๐—ฟ ๐—ฃ๐—ผ๐˜„๐—ฒ๐—ฟ ๐—•๐—œ ๐—ณ๐—ผ๐—ฟ ๐—™๐—ฅ๐—˜๐—˜! ๐Ÿ”ฅ Learn Power BI through these FREE learninโ€ฆ
  5. Sep 29, 2026SQL Interview Series โ€” Part 2 ๐Ÿ“Œ Question 2: Find Duplicate Records Suppose you have an Emโ€ฆ
  6. Sep 29, 2026๐—™๐—ฅ๐—˜๐—˜ ๐—ฅ๐—ฒ๐˜€๐—ผ๐˜‚๐—ฟ๐—ฐ๐—ฒ๐˜€ ๐—ง๐—ผ ๐—Ÿ๐—ฒ๐—ฎ๐—ฟ๐—ป ๐—”๐—œ ๐—ถ๐—ป ๐Ÿฎ๐Ÿฌ๐Ÿฎ๐Ÿฒ๐Ÿš€ โ€‹ Explore 6 free resourceโ€ฆ
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook โ†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 โ†’