Revenue concentration is a hidden business risk. This query ranks your customers by invoice revenue and shows year-over-year growth so you can spot your most valuable accounts and identify concentration risk.
This is part of the Taptic Data QuickBooks query library. Explore related queries: SQL query for QuickBooks net income by month and SQL query for QuickBooks overdue invoices by customer.
The question
The SQL Taptic generates
WITH customer_revenue AS ( SELECT c.display_name AS customer, SUM(CASE WHEN i.txn_date >= DATE_TRUNC('year', CURRENT_DATE) THEN il.amount ELSE 0 END) AS current_year, SUM(CASE WHEN i.txn_date >= DATE_TRUNC('year', CURRENT_DATE) - INTERVAL '1 year' AND i.txn_date < DATE_TRUNC('year', CURRENT_DATE) THEN il.amount ELSE 0 END) AS prior_year FROM qbo_invoices i JOIN qbo_invoice_line_items il ON il.invoice_id = i.id JOIN qbo_customers c ON c.id = i.customer_id WHERE i.txn_date >= DATE_TRUNC('year', CURRENT_DATE) - INTERVAL '1 year' GROUP BY c.display_name ) SELECT customer, ROUND(current_year::numeric, 2) AS current_year_revenue, ROUND(prior_year::numeric, 2) AS prior_year_revenue, ROUND((current_year - prior_year)::numeric, 2) AS change, ROUND( (current_year - prior_year) / NULLIF(prior_year, 0) * 100, 1 ) AS yoy_growth_pct, ROUND(current_year * 100.0 / NULLIF(SUM(current_year) OVER (), 0), 1) AS pct_of_total FROM customer_revenue WHERE current_year > 0 ORDER BY current_year DESC LIMIT 25
This query was generated by Taptic Data from plain English against a real QuickBooks Online 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
Top 25 customers by current year revenue with prior year comparison, growth rate, and percentage of total revenue.
Why it matters
FAQ
Generate this automatically
In Taptic Data, you type "Show me revenue by customer this year vs last year with grow..." and this SQL runs automatically against your real QuickBooks Online data.
Try Taptic Free — $29.99/moNo credit card required. Connect your data source in under 5 minutes.
Compare tools