SQL templates for Stripe, Shopify and Supabase data
For founders who want answers from their own billing, store or app data. Each page has a short main query, the tables it assumes for each source, copy-ready variations, and the mistakes that make the numbers wrong.
Running Postgres? See the PostgreSQL SQL generator. Want to ask from Claude, Cursor or ChatGPT instead? Set up AI2SQL over MCP.
Stripe
MRR, churn and failed payments, in Stripe Sigma (Trino) or on Stripe data synced to your warehouse.
15 Stripe Sigma SQL Queries Founders Actually Use 15 copy-ready Stripe Sigma queries: subscribers, MRR, ARPA, trials, cancellations, revenue and fees, refunds, failed charges, disputes, top customers. Stripe Churn Rate SQL: Customer and Revenue Churn SQL for Stripe churn: customer (logo) churn, gross MRR churn and net revenue retention, monthly trend. Sigma, Fivetran and Airbyte versions. Stripe Data in Your Warehouse: SQL for Snowflake and BigQuery SQL for Stripe data in Snowflake and BigQuery: MRR, revenue after fees, failed payments, revenue by signup cohort. Data Pipeline, Fivetran and Airbyte. Stripe Failed Payments and Past-Due Subscriptions in SQL SQL for Stripe failed payments: decline codes, past-due subscriptions with amounts owed, invoices in retry, recovered revenue. Sigma, Fivetran and Airbyte. Stripe MRR SQL Query: Sigma, Data Pipeline & Fivetran Copy-ready SQL for Stripe MRR in Sigma, Stripe Data Pipeline and Fivetran: current MRR, MRR by month, new vs churned MRR. Cents and annual plans handled.
Shopify
Orders, customers and products synced to Postgres, Snowflake or BigQuery. Each page has a version that runs on demo data.
Shopify Customer LTV and Repeat Purchase Rate in SQL SQL for Shopify customer lifetime value and repeat purchase rate: overall, by cohort, by channel and first product, net of refunds. Runs on demo data. RUNS ON DEMO DATA Shopify Data Warehouse Schema: Orders, Products, Customers and SQL Shopify data warehouse schema: order, order_line, customer, product and variant tables, keys and joins, star-schema views, SQL Server DDL and queries. RUNS ON DEMO DATA Shopify SQL Queries: 15 Templates for Orders and Customers 15 copy-ready SQL queries for Shopify data in Postgres, Snowflake or BigQuery: revenue, AOV, top products, new vs returning customers, refunds, stock. RUNS ON DEMO DATA
Supabase
Postgres queries for the Supabase SQL editor, including signups and active users from auth.users.
Query Supabase auth.users: Signups, Active Users and Cohorts SQL on Supabase auth.users for founders: signups per day and week, active users (DAU/WAU/MAU), activation within 7 days, weekly retention cohorts. PARTLY RUNS ON DEMO DATA Supabase SQL Examples: 15 Copy-Ready Queries 15 copy-ready Supabase SQL queries for the SQL editor: users and signups, profiles trigger, RLS policies, retention, table sizes, missing indexes. PARTLY RUNS ON DEMO DATA