HomeQuery LibraryQuickBooks

Which customers drive your revenue — and which are growing fastest?

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.

📊 QuickBooks Online👥 Finance and sales teams🔤 Plain-English → SQL

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.

Show me revenue by customer this year vs last year with growth rate
QuickBooks Revenue by Customer — generated by Taptic Data AI
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
Schema-aware SQL generated from plain English33 lines

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.

Breaking it down line by line

  1. CASE statements separate revenue into current year and prior year in a single pass
  2. Window function SUM OVER () calculates each customer's share of total revenue without a subquery
  3. YoY growth percentage shows which customers are expanding and which are contracting
  4. pct_of_total reveals revenue concentration — if your top 3 customers represent 60%+, that is a risk
  5. NULLIF prevents division by zero for new customers with no prior-year revenue

Result description

Top 25 customers by current year revenue with prior year comparison, growth rate, and percentage of total revenue.

The business impact

Knowing which customers are growing and which are declining — and what percentage of your total revenue each represents — is foundational to account management, retention prioritization, and risk assessment. A customer contributing 25% of revenue that is declining 15% YoY demands attention.

Common questions

How do I generate a "QuickBooks Revenue by Customer" query automatically?
In Taptic Data, type "Show me revenue by customer this year vs last year with growth rate" and the AI generates schema-aware SQL against your real QuickBooks Online data — no manual writing required.
What database does this query work with?
This query is designed for QuickBooks Online. Taptic reads your live schema so the generated SQL always matches your actual table and column names.
Can I edit the generated SQL?
Yes. Taptic shows you the exact SQL it generated. You can edit it directly, ask the AI to explain any line, or request a revision in plain English.
Can I save this as a scheduled report?
Yes. Once you run this query in Taptic, you can save it as a report, add charts and KPIs, and schedule it to email your team on any cadence — daily, weekly, or monthly.

Skip the SQL. Ask the question.

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

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