Skip to main content
Back to Prompt Library
SQL & DataPostgreSQL CTE + Window FunctionsCoding & Engineering/sql

SaaS Revenue Cohort Retention & Net Dollar Expansion SQL

Self-contained PostgreSQL query with synthetic CTE dataset computing monthly logo retention, MRR expansion, contraction, and churn.

Ready-to-Run Prompt Template

Mode: normal
Write a complete, runnable PostgreSQL query using WITH CTE sample data that computes monthly SaaS Cohort Retention, Net Dollar Retention (NDR), expansion MRR, and churned MRR using window functions. Also recommend composite indexes and explain the query plan.
Recommended Model
Fusta Core
Studio Mode
normal
Access
Free in Browser

Recommended Fusta Skills for This Prompt

SQL, Database & Data Engineer

Writes production PostgreSQL/ClickHouse/Firestore schemas, window-function analytics, and index tuning plans.

QA & Edge-Case Verifier

Audits code for race conditions, off-by-one errors, XSS/injection flaws, and runs an agentic post-generation review on complex code.

More Ready-to-Run Templates