Querying your data (SQL)
Once data is in an artifact source, queries turn it into the numbers behind your dashboards and role metrics. Each source behaves like a table you can select from — named by the source, with the columns you defined.
A safe subset of SQL
Section titled “A safe subset of SQL”Queries are read-only SQL — a deliberately limited subset of PostgreSQL:
SELECTonly — no inserting, updating, or deleting data.- A whitelist of functions and casts — the common ones for reporting (aggregates, dates, string and math functions) are available.
- Org-scoped automatically — a query only ever sees your own organization’s data, and runs under a short time limit so a heavy query can’t slow things down.
In short: it’s safe to let anyone explore data with a query.
Variables
Section titled “Variables”A query can take variables — :name placeholders you fill in at run time —
so one query answers many questions:
SELECT created_at::date AS date, count(*) AS prsFROM github_prsWHERE created_at > :start_date::timestamptzGROUP BY 1ORDER BY 1- Dashboards supply variables through interactive controls (a date picker, a team selector, and so on) — see Dashboards.
- Role metrics must include a
:staff_idvariable; Admire runs the query per person, filling in each staff member’s ID — see Role metrics.
Examples
Section titled “Examples”A grouped count for a dashboard chart:
SELECT state, count(*) AS totalFROM github_prsGROUP BY stateA per-person time series for a role metric (date + value, scoped by
:staff_id):
SELECT closed_at::date AS date, count(*) AS tickets_closedFROM support_ticketsWHERE assignee_id = :staff_idGROUP BY 1ORDER BY 1Plain-English vs. SQL
Section titled “Plain-English vs. SQL”You don’t need to know SQL. In English mode, describe what you want and Admire drafts the query for you — it knows your sources’ tables and columns, so the result usually just works, and you can refine it in plain English. Prefer to write it yourself? Switch to SQL mode and author the query directly. You can move between the two at any time.