The product performance matrix combines revenue, units sold, refund rate, and repeat purchase contribution into a single ranked view. Identify your best and worst performers at a glance.
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 product_sales AS ( SELECT li.product_id, MAX(li.title) AS product_name, SUM(li.quantity) AS units_sold, ROUND(SUM(li.price * li.quantity)::numeric, 2) AS revenue, COUNT(DISTINCT o.customer_id) AS unique_buyers FROM shopify_order_line_items li JOIN shopify_orders o ON o.id = li.order_id WHERE o.financial_status IN ('paid', 'partially_refunded') AND o.cancelled_at IS NULL AND o.created_at >= NOW() - INTERVAL '90 days' GROUP BY li.product_id ), product_refunds AS ( SELECT li.product_id, SUM(li.quantity) AS units_refunded FROM shopify_refunds r JOIN shopify_order_line_items li ON li.order_id = r.order_id WHERE r.created_at >= NOW() - INTERVAL '90 days' GROUP BY li.product_id ), repeat_buyers AS ( SELECT product_id, COUNT(DISTINCT customer_id) AS repeat_count FROM ( SELECT li.product_id, o.customer_id FROM shopify_order_line_items li JOIN shopify_orders o ON o.id = li.order_id WHERE o.financial_status IN ('paid', 'partially_refunded') AND o.cancelled_at IS NULL GROUP BY li.product_id, o.customer_id HAVING COUNT(DISTINCT o.id) > 1 ) sub GROUP BY product_id ) SELECT ps.product_name, ps.revenue, ps.units_sold, ps.unique_buyers, COALESCE(pr.units_refunded, 0) AS units_refunded, ROUND(COALESCE(pr.units_refunded, 0)::numeric * 100 / NULLIF(ps.units_sold, 0), 1) AS refund_rate_pct, COALESCE(rb.repeat_count, 0) AS repeat_buyers, ROUND(COALESCE(rb.repeat_count, 0)::numeric * 100 / NULLIF(ps.unique_buyers, 0), 1) AS repeat_buyer_pct FROM product_sales ps LEFT JOIN product_refunds pr USING (product_id) LEFT JOIN repeat_buyers rb USING (product_id) WHERE ps.units_sold >= 10 ORDER BY ps.revenue DESC LIMIT 30
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.
How this query works
What it returns
Per-product performance view with revenue, units, refund rate, unique buyers, and repeat buyer percentage โ your complete product health scorecard.
Why it matters
FAQ
Generate this automatically
In Taptic Data, you type "Show me a product performance matrix with revenue, units, re..." 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.
Compare tools