Net income is the single most important number in your P&L. This query pulls it from QuickBooks month by month, with year-over-year comparison built in.
The question
The SQL Taptic generates
SELECT TO_CHAR(DATE_TRUNC('month', i.txn_date), 'YYYY-MM') AS month, ROUND(SUM(CASE WHEN i.doc_number IS NOT NULL THEN il.amount ELSE 0 END)::numeric, 2) AS gross_revenue, ROUND(SUM(CASE WHEN e.account_type = 'Expense' THEN e.total_amount ELSE 0 END)::numeric, 2) AS total_expenses, ROUND( SUM(CASE WHEN i.doc_number IS NOT NULL THEN il.amount ELSE 0 END)::numeric - SUM(CASE WHEN e.account_type = 'Expense' THEN e.total_amount ELSE 0 END)::numeric , 2) AS net_income, LAG( ROUND(SUM(CASE WHEN i.doc_number IS NOT NULL THEN il.amount ELSE 0 END)::numeric - SUM(CASE WHEN e.account_type = 'Expense' THEN e.total_amount ELSE 0 END)::numeric, 2), 12 ) OVER (ORDER BY DATE_TRUNC('month', i.txn_date)) AS prior_year_net_income FROM qbo_invoices i JOIN qbo_invoice_line_items il ON il.invoice_id = i.id LEFT JOIN qbo_expenses e ON DATE_TRUNC('month', e.txn_date) = DATE_TRUNC('month', i.txn_date) WHERE i.txn_date >= NOW() - INTERVAL '24 months' GROUP BY DATE_TRUNC('month', i.txn_date) 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. This type of analysis is commonly used in quickbooks financial reporting and multi-channel analytics.
How this query works
What it returns
Monthly net income for 24 months with gross revenue, total expenses, net income, and prior year net income side by side — ready to chart as a trend.
Why it matters
All queries and use cases on this page relate to analyzing your QuickBooks Online data in Taptic. To see the full analytics workflow, explore quickbooks financial reporting, multi-channel analytics.
FAQ
Generate this automatically
In Taptic Data, you type "Show me net income by month for the last 12 months compared ..." 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.
Related use cases