How to calculate Units per Transaction
Units per transaction is the average number of items in each order or basket.
Formula
Units per transaction = total units sold ÷ number of transactionsSQL query
This example assumes: order_items(order_id, product_id, quantity), orders(id, status). It is written in PostgreSQL syntax; date functions differ slightly in MySQL, BigQuery and SQLite, and your column names will differ from these.
SELECT SUM(i.quantity) * 1.0 / NULLIF(COUNT(DISTINCT i.order_id), 0) AS units_per_transaction
FROM order_items i
JOIN orders o ON o.id = i.order_id
WHERE o.status = 'paid';Common mistakes that make Units per Transaction wrong
- Bundles that expand into several lines inflate unit counts.
- Joining order items to payments can duplicate rows; count distinct orders.
- Free gifts count as units but not revenue.
Ask for Units per Transaction 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 is the average basket size by month?
- Do customers buy more items per order on mobile or desktop?