SaaS and subscription metrics: formulas and SQL

Metrics for recurring revenue, churn and retention. Small definition differences (monthly vs annual, logo vs revenue, gross vs net) change the answer a lot, so state which one you mean.