How to calculate Marketing ROI

Marketing ROI compares the profit generated by marketing against what it cost, expressed as a percentage.

Formula

Marketing ROI = (gross profit from marketing − marketing cost) ÷ marketing cost × 100

SQL query

This example assumes: spend(month, amount), orders(id, ordered_at, revenue, cost_of_goods, marketing_attributed). It is written in PostgreSQL syntax; date functions differ slightly in MySQL, BigQuery and SQLite, and your column names will differ from these.

WITH profit AS (
  SELECT SUM(revenue - cost_of_goods) AS gross_profit
  FROM orders
  WHERE marketing_attributed AND ordered_at >= DATE '2026-07-01'
), cost AS (
  SELECT SUM(amount) AS spend FROM spend WHERE month >= DATE '2026-07-01'
)
SELECT (profit.gross_profit - cost.spend) * 100.0 / NULLIF(cost.spend, 0) AS roi_pct
FROM profit, cost;

Common mistakes that make Marketing ROI wrong

  • Using revenue instead of profit overstates the return.
  • Long sales cycles mean this quarter's spend produces next quarter's revenue.
  • Attribution is a rule, not a fact; the same data supports several ROI numbers.

Ask for Marketing ROI in plain English

Instead of writing the query yourself, you can type the question. SchemaChat turns it into SQL against your connected database or uploaded file, runs it, and shows the SQL and the figures it used so you can check the answer before you share it. It does not replace your judgement about the definition: check that the query matches the formula your business uses.

  • What was our marketing ROI this quarter?
  • How does marketing ROI change if we use gross profit instead of revenue?

Frequently asked questions

What is Marketing ROI?
Marketing ROI compares the profit generated by marketing against what it cost, expressed as a percentage.
How do you calculate Marketing ROI?
Marketing ROI = (gross profit from marketing − marketing cost) ÷ marketing cost × 100. The SQL example on this page shows the same calculation against a simple table.
What commonly goes wrong when calculating Marketing ROI?
Using revenue instead of profit overstates the return.