HomeQuery LibraryQuickBooks

How much cash came in, went out, and what is the trend?

Cash flow is the lifeblood of small business. This query compares payments received vs expenses paid by month so you can see whether you are cash-positive or cash-negative — and which direction the trend is heading.

📊 QuickBooks Online👥 Finance teams and business owners🔤 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 monthly cash flow — payments received vs expenses paid for the last 12 months
QuickBooks Cash Flow Summary — generated by Taptic Data AI
WITH cash_in AS (
  SELECT
    DATE_TRUNC('month', p.txn_date)::date  AS month,
    ROUND(SUM(p.total_amount)::numeric, 2) AS payments_received
  FROM qbo_payments p
  WHERE p.txn_date >= NOW() - INTERVAL '12 months'
  GROUP BY 1
),
cash_out AS (
  SELECT
    DATE_TRUNC('month', e.txn_date)::date  AS month,
    ROUND(SUM(e.total_amount)::numeric, 2) AS expenses_paid
  FROM qbo_expenses e
  WHERE e.txn_date >= NOW() - INTERVAL '12 months'
  GROUP BY 1
)
SELECT
  TO_CHAR(COALESCE(ci.month, co.month), 'YYYY-MM') AS month,
  COALESCE(ci.payments_received, 0)                  AS cash_in,
  COALESCE(co.expenses_paid, 0)                      AS cash_out,
  COALESCE(ci.payments_received, 0)
    - COALESCE(co.expenses_paid, 0)                  AS net_cash_flow,
  SUM(COALESCE(ci.payments_received, 0)
    - COALESCE(co.expenses_paid, 0))
    OVER (ORDER BY COALESCE(ci.month, co.month))     AS cumulative_net
FROM cash_in ci
FULL OUTER JOIN cash_out co USING (month)
ORDER BY month ASC
Schema-aware SQL generated from plain English28 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. CTE "cash_in" sums payments received from the qbo_payments table by month
  2. CTE "cash_out" sums expenses paid from the qbo_expenses table by month
  3. FULL OUTER JOIN handles months that may have income but no expenses or vice versa
  4. Net cash flow per month = payments received minus expenses paid
  5. Cumulative net uses a window function to show the running total — your cash position trend

Result description

Monthly cash flow with payments received, expenses paid, net cash flow, and a cumulative running total for trend analysis.

The business impact

Net income on the P&L does not equal cash in the bank. Revenue recognized but not yet collected, expenses accrued but not yet paid — these timing differences kill businesses with healthy income statements. A monthly cash flow view reveals the real story.

Common questions

How do I generate a "QuickBooks Cash Flow Summary" query automatically?
In Taptic Data, type "Show me monthly cash flow — payments received vs expenses paid for the last 12 months" 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 monthly cash flow — payments received vs expenses pa..." 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.