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.
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 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
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
Monthly cash flow with payments received, expenses paid, net cash flow, and a cumulative running total for trend analysis.
Why it matters
FAQ
Generate this automatically
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/moNo credit card required. Connect your data source in under 5 minutes.
Compare tools