Repeat purchase rate is a proxy for customer satisfaction, product-market fit, and brand loyalty. This query breaks it down by month so you can see whether your retention is improving.
This is part of the Taptic Data Shopify query library. Explore related queries: SQL query for Shopify revenue by month, SQL query for Shopify customer lifetime value, SQL query for Shopify refund rate by product, and more.
The question
The SQL Taptic generates
WITH customer_order_history AS ( SELECT customer_id, id AS order_id, total_price, created_at, ROW_NUMBER() OVER ( PARTITION BY customer_id ORDER BY created_at ASC ) AS order_sequence FROM shopify_orders WHERE financial_status IN ('paid', 'partially_refunded') AND customer_id IS NOT NULL ) SELECT TO_CHAR(DATE_TRUNC('month', created_at), 'YYYY-MM') AS order_month, COUNT(*) FILTER (WHERE order_sequence = 1) AS new_customer_orders, COUNT(*) FILTER (WHERE order_sequence > 1) AS repeat_customer_orders, COUNT(*) AS total_orders, ROUND(SUM(total_price) FILTER (WHERE order_sequence = 1)::numeric, 2) AS new_revenue, ROUND(SUM(total_price) FILTER (WHERE order_sequence > 1)::numeric, 2) AS repeat_revenue, ROUND( COUNT(*) FILTER (WHERE order_sequence > 1)::numeric * 100 / NULLIF(COUNT(*), 0), 2 ) AS repeat_order_pct, ROUND( SUM(total_price) FILTER (WHERE order_sequence > 1)::numeric * 100 / NULLIF(SUM(total_price)::numeric, 0), 2 ) AS repeat_revenue_pct FROM customer_order_history WHERE created_at >= NOW() - INTERVAL '12 months' GROUP BY DATE_TRUNC('month', created_at) ORDER BY 1 ASC
This query was generated by Taptic Data from plain English against a real Shopify schema. In Taptic, you type the question — the AI writes the SQL, runs it, and returns the result. You can edit the SQL, ask for explanations, and save it as a refreshable report. This type of analysis is commonly used in shopify revenue dashboard and ecommerce reporting.
How this query works
What it returns
Monthly breakdown of new vs repeat customer orders and revenue, with percentage of each — covering the last 12 months to reveal retention trends.
Why it matters
New to this metric? How to calculate Shopify repeat purchase rate — definition, formula, and business context.
All queries and use cases on this page relate to analyzing your Shopify data in Taptic. To see the full analytics workflow, explore shopify revenue dashboard, ecommerce reporting.
FAQ
Generate this automatically
In Taptic Data, you type "Show me what percentage of revenue and orders come from repe..." and this SQL runs automatically against your real Shopify data.
Try Taptic Free — $29.99/moNo credit card required. Connect your data source in under 5 minutes.
Related use cases
Compare tools