How to calculate Return on Investment (ROI)

Return on investment compares the gain from an investment with its cost, as a percentage.

Formula

ROI % = (gain from investment − cost of investment) ÷ cost of investment × 100

SQL query

This example assumes: investments(id, name, cost, return_amount). It is written in PostgreSQL syntax; date functions differ slightly in MySQL, BigQuery and SQLite, and your column names will differ from these.

SELECT name,
       cost,
       return_amount,
       (return_amount - cost) * 100.0 / NULLIF(cost, 0) AS roi_pct
FROM investments
ORDER BY roi_pct DESC;

Common mistakes that make Return on Investment (ROI) wrong

  • ROI ignores time: 50% in one year and 50% in five years are very different.
  • Count all costs, including staff time and ongoing running costs.
  • Attributing gains to a single investment is a judgement; be explicit about it.

Ask for Return on Investment (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 the ROI on each project last year?
  • Which investments returned less than they cost?

Frequently asked questions

What is Return on Investment (ROI)?
Return on investment compares the gain from an investment with its cost, as a percentage.
How do you calculate Return on Investment (ROI)?
ROI % = (gain from investment − cost of investment) ÷ cost of investment × 100. The SQL example on this page shows the same calculation against a simple table.
What commonly goes wrong when calculating Return on Investment (ROI)?
ROI ignores time: 50% in one year and 50% in five years are very different.