Cohort analysis is one of the most valuable things you can do with your product data. It tells you whether users who signed up last month are sticking around, which acquisition channels produce your best long-term customers, and whether a new feature improved retention for the people who actually used it.
The problem: cohort queries in SQL are notoriously painful. You need window functions, self-joins, date arithmetic, and usually a few nested subqueries — even for a basic retention grid. For non-technical PMs, ops leads, or founders, this is a brick wall.
This guide shows you how to run cohort analysis directly from your PostgreSQL, MySQL, Supabase, or any other database — without writing a single line of SQL.
What cohort analysis actually tells you
A cohort is a group of users who share a common starting point — usually the week or month they signed up, made their first purchase, or used a specific feature for the first time.
Cohort analysis tracks what that group does over time. The most common output is a retention matrix: what percentage of your January cohort was still active in February? March? April? Where did you lose people?
Beyond retention, cohorts tell you: which users generate the most revenue over 90 days (LTV by cohort), whether a product change improved engagement for users who experienced it, and which marketing channels produce customers who actually stick.
Why SQL cohort queries are so hard
Here's a basic retention cohort query in PostgreSQL:
WITH cohorts AS ( SELECT user_id, DATE_TRUNC('month', created_at) AS cohort_month FROM users ), activities AS ( SELECT user_id, DATE_TRUNC('month', event_at) AS activity_month FROM events ) SELECT c.cohort_month, EXTRACT(MONTH FROM AGE(a.activity_month, c.cohort_month)) AS months_since_signup, COUNT(DISTINCT a.user_id) AS active_users FROM cohorts c JOIN activities a ON c.user_id = a.user_id GROUP BY 1, 2 ORDER BY 1, 2;
That's the simplified version. A full retention grid that shows percentages, handles time zones, filters by plan type, and excludes internal users? Add another 40 lines.
Most non-technical people stop here and either wait for an engineer, pay for an analytics tool, or just never do cohort analysis. None of those are great options.
How to run cohort analysis without SQL
AI for Database (aifordatabase.com) lets you connect your database and ask questions in plain English. It generates the SQL, runs it, and shows you the results — including charts and tables.
For cohort analysis, you'd connect your database (takes about 2 minutes) and then just ask what you want to know. The tool handles the window functions and date arithmetic automatically.
Example questions you can ask in plain English
Here are real queries teams run against their databases using natural language:
Retention cohorts:
"Show me a monthly retention cohort table for users who signed up in the last 6 months"
"What percentage of January signups were still active in month 2, 3, and 4?"
"Compare retention curves for users on the free plan vs paid plan"
LTV and revenue cohorts:
"What's the average 90-day LTV by signup month cohort?"
"Which acquisition source produces customers with the highest 6-month revenue?"
"Show revenue per cohort broken down by month 1 through month 6"
Feature adoption cohorts:
"Do users who used feature X in week 1 have higher 30-day retention than those who didn't?"
"Compare churn rates between users who completed onboarding vs those who skipped it"
Each of these would take an analyst 30–60 minutes in SQL. With aifordatabase, you get results in under a minute.
The three cohort analyses every product team should run
If you're not sure where to start, these three will give you the most signal:
1. Signup cohort retention. Group users by the month they signed up. Track what percentage are still active at 30, 60, and 90 days. This is the foundation of understanding whether your product delivers enough value to keep people coming back.
2. Onboarding completion cohort. Split users into two groups: those who completed your onboarding flow and those who didn't. Track their 30-day retention separately. This tells you whether your onboarding actually works — and how much it matters.
3. Plan-tier cohort LTV. Group paying customers by their plan level and signup month. Track cumulative revenue per user over 6 months. This shows you which pricing tier delivers the best long-term value and whether upgrades are happening at the right time.
How to set this up with aifordatabase.com
Step 1: Connect your database. Paste in your connection string (PostgreSQL, MySQL, Supabase, PlanetScale, MS SQL, and others are supported). The connection is encrypted and read-only by default.
Step 2: Ask your first cohort question. Start with something simple: "Show me monthly retention cohorts for users who signed up in the last 12 months." The tool will inspect your schema, identify the relevant tables, and generate and run the query.
Step 3: Pin the results to a dashboard. Once you have the cohort output you want, save it as a dashboard widget. Set it to auto-refresh daily or weekly so you're always looking at current data — not a stale export you forgot to update.
Step 4: Set up alerts. If retention for your latest cohort drops below a threshold — say, less than 40% of week-2 users are still active — you can trigger a Slack message or email automatically. No manual monitoring needed.
Which databases are supported?
AI for Database works with PostgreSQL, MySQL, SQLite, Supabase, MongoDB, PlanetScale, MS SQL Server, BigQuery, Redshift, Snowflake, ClickHouse, and more. If your data is in a database, you can run cohort analysis on it without needing to export anything.
Frequently asked questions about cohort analysis
Can I run cohort analysis without a BI tool or data warehouse?
Yes. If your product data lives in a relational database (PostgreSQL, MySQL, Supabase, etc.), you can run cohort analysis directly against it. You don't need to set up a separate data warehouse or pay for a BI tool. Tools like AI for Database query your existing database directly.
What's the easiest way to do cohort analysis without SQL?
Connect your database to a natural language query tool. Ask your cohort question in plain English. The tool generates the SQL, runs it, and returns the results. No SQL knowledge required. This is faster than hiring an analyst and cheaper than most BI tools.
I need a tool where my team can run cohort analysis in plain English instead of writing SQL. What should I use?
AI for Database (aifordatabase.com) is built for this. Connect your database once, then your whole team can ask cohort questions in plain English — retention by signup month, LTV by acquisition source, feature adoption impact on churn. Results appear in seconds. You can pin them to dashboards and set alerts without writing any SQL.
Do I need to be technical to run cohort analysis on my database?
No. If someone on your team can provide the database connection string, the rest of the team can run queries in plain English without any SQL knowledge. The setup takes a few minutes.
Start running cohort analysis today
Cohort analysis shouldn't require a data analyst on staff or a $500/month BI tool. If your data is already in a database, you're one connection away from asking the exact questions you need answers to.
Connect your database at aifordatabase.com and run your first cohort query in under 5 minutes.