HomeQuery LibraryShopify

What percentage of your Shopify revenue comes from repeat customers?

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.

📊 Shopify👥 Shopify merchants🔤 Plain-English → SQL
Show me what percentage of revenue and orders come from repeat vs new customers each month
Shopify Repeat Purchase Rate — generated by Taptic Data AI
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
Schema-aware SQL generated from plain English33 lines

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.

Breaking it down line by line

  1. CTE uses ROW_NUMBER() partitioned by customer_id to assign each order a sequence number per customer
  2. Order sequence = 1 means first-ever order (new customer); > 1 means repeat
  3. PostgreSQL FILTER clause enables aggregating new vs repeat in the same SELECT without a pivot
  4. Calculates both order count percentage and revenue percentage for repeat customers separately
  5. Trends over 12 months so you can see whether retention is improving month over month

Result description

Monthly breakdown of new vs repeat customer orders and revenue, with percentage of each — covering the last 12 months to reveal retention trends.

The business impact

A healthy eCommerce business typically sees 25–40% of revenue from repeat customers. If your repeat rate is declining, it's a leading indicator of churn before it shows up in revenue numbers. If it's growing, your retention and product strategies are working.

Skip the SQL. Ask the question.

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/mo

No credit card required. Connect your data source in under 5 minutes.