Skip to content

Every query starts with FROM and the object to report on, followed by SHOW and the numbers you want.

FROM deals
SHOW count, value, won_value
FROM <object>

FROM takes one object: deals, contacts, invoices, orders, subscriptions and so on. The Objects page lists them all, with what each one holds and whether it can be combined with others.

SHOW <metric>[, <metric> ...]

SHOW takes one or more metrics, separated by commas.

Form Example Result
A metric of the object SHOW count, won_value The catalog metric
A related object’s metric SHOW deals.won_value The metric of the linked records
Renamed SHOW won_value AS revenue The column is called revenue
Scaled SHOW won_value * 12 AS ARR The metric times a number
Math SHOW won_value / won_count AS avg_won A calculated metric
A function of a field SHOW avg(amount), sum(mrr) See Functions
Filtered SHOW count FILTER (WHERE stage = "MQL") The metric over only the matching records

Combine metrics with + - * / and parentheses:

FROM deals
SHOW won_value * 12 AS ARR,
won_value / won_count AS avg_won,
won_count * 100 / count AS win_pct
GROUP BY owner

Dividing by zero shows an empty value. In tables, a calculated rate is totaled from its parts, so the totals row stays correct. Money stays money: won_value / won_count is shown as currency, while won_value / value is a plain number.

When the object can be combined, show the metrics of linked records next to its own:

FROM contacts
SHOW count, deals.count, deals.won_value, orders.total
GROUP BY source

Each object keeps its own permissions and data visibility, and its own date: deals.won_value counts the deals won in the period, and a time grouping such as GROUP BY month puts each deal in the month it was won, while count puts each contact in the month it was created.

WHERE applies to every metric in the query. To count only some records for one metric, add FILTER (WHERE …) after it:

FROM contacts
SHOW count AS "Marketing contacts",
count FILTER (WHERE stage = "MQL") AS MQL,
deals.won_count FILTER (WHERE stage = "Closed Paid") AS "Closed Paid"
WHERE source = "Marketing Generated"
TIMESERIES month

Each month shows the marketing contacts created that month, the ones of them now in the MQL stage, and the Closed Paid deals of marketing contacts won that month.

  • The conditions use the metric’s own object: count FILTER (WHERE stage = "MQL") filters contacts, deals.won_count FILTER (WHERE stage = "Closed Paid") filters deals. To narrow every metric, use WHERE.
  • A filtered metric keeps its meaning and its date: won_count still counts only won deals, by the date they were won.
  • It works in math, such as an MQL rate: count FILTER (WHERE stage = "MQL") * 100 / count AS mql_rate.
  • Name it with AS to sort, chart or check it in HAVING. Without a name, the column is labelled with the metric and the options it keeps, such as “Contacts (MQL)”.
  • It works on objects that can be combined, and not in a COHORT report.
-- Revenue and order count this month
FROM orders
SHOW total, count
DURING this_month
-- Average won deal per owner
FROM deals
SHOW won_value / won_count AS avg_won
GROUP BY owner
DURING this_year
ON won_at