# Syntax overview

> How a RepzoQL query is put together: clauses, names, values, comments, and errors.

A RepzoQL query is a few lines of text, one clause per line. It starts with `FROM` and the object to report on; the other clauses can come in any order, and each is used once.

```sql
FROM deals
SHOW count, won_value
GROUP BY owner
WHERE stage != "Lost"
DURING this_quarter
COMPARE TO previous_quarter
ORDER BY won_value DESC
LIMIT 10
VISUALIZE won_value TYPE horizontal_bar
```

## Clauses

| Clause | What it does | Reference |
|---|---|---|
| `FROM` | The object to report on | [FROM and SHOW](https://workstation.repzo.com/docs/analytics/repzoql/from-and-show) |
| `SHOW` | The numbers to show | [FROM and SHOW](https://workstation.repzo.com/docs/analytics/repzoql/from-and-show) |
| `WHERE` | Only count matching records | [WHERE](https://workstation.repzo.com/docs/analytics/repzoql/where) |
| `GROUP BY` | Split the numbers by fields | [GROUP BY](https://workstation.repzo.com/docs/analytics/repzoql/group-by) |
| `TIMESERIES` | Split by time, with no gaps | [TIMESERIES](https://workstation.repzo.com/docs/analytics/repzoql/timeseries) |
| `SINCE`, `UNTIL`, `DURING`, `ON` | The period and the date it uses | [SINCE, UNTIL, DURING](https://workstation.repzo.com/docs/analytics/repzoql/since-until-during) |
| `COMPARE TO` | A second period to compare with | [COMPARE TO](https://workstation.repzo.com/docs/analytics/repzoql/compare-to) |
| `WITH` | Totals, percent change, running totals, currency, time zone | [WITH](https://workstation.repzo.com/docs/analytics/repzoql/with) |
| `HAVING` | Keep only groups whose numbers match | [HAVING](https://workstation.repzo.com/docs/analytics/repzoql/having) |
| `ORDER BY`, `LIMIT`, `OFFSET` | Sort and page the rows | [ORDER BY and LIMIT](https://workstation.repzo.com/docs/analytics/repzoql/order-by-and-limit) |
| `COHORT` | Follow people from their first record | [COHORT](https://workstation.repzo.com/docs/analytics/repzoql/cohort) |
| `VISUALIZE` | Pick the chart | [VISUALIZE](https://workstation.repzo.com/docs/analytics/repzoql/visualize) |

## Names

Objects, metrics, and fields are written by name. Names come from each object's catalog and from [Properties](https://workstation.repzo.com/docs/administration/properties), so custom properties work too.

- A field is written as its name: `stage`, `owner`, `close_date`.
- A custom property can be written as its label in snake case (`customer_tier`) or in double quotes (`"Customer tier"`).
- A related object's metric or field takes the object name and a dot: `deals.won_value`, `accounts.industry`. See [Related records](https://workstation.repzo.com/docs/analytics/report-queries#related-records).

The [Objects](https://workstation.repzo.com/docs/analytics/repzoql/objects) page lists every object. The editor's book icon lists each object's metrics and fields.

## Values

| Kind | Examples |
|---|---|
| Text and options | `"Won"`, `"Website"`, `"Sam Seller"` (always in double quotes) |
| Numbers | `1000`, `12.5` |
| Dates | `2026-01-31`, `-30d`, `startOfMonth(-1m)`, `last_month` |
| Yes / no | `IS TRUE`, `IS FALSE` |
| The viewer | `me`, as in `owner = me` |

Option values use the option's name. A stage name used by several pipelines matches all of them; write `"Won (Sales)"` to pick one.

## Keywords and comments

Keywords can be upper or lower case. Line comments start with `--`; block comments go between `/*` and `*/`.

```sql
FROM deals -- every deal
/* won value by owner,
   this quarter only */
SHOW won_value
GROUP BY owner
DURING this_quarter
```

## Errors

The editor checks the query as you type. A mistake is underlined, the card shows the line and a short explanation, and close matches are offered as fixes: "Did you mean `count`?". The same message, with its line and column, comes back from the [API](https://workstation.repzo.com/docs/analytics/report-queries#using-queries-from-the-api).

## Related pages

- [Report queries](https://workstation.repzo.com/docs/analytics/report-queries): getting started
- [Functions](https://workstation.repzo.com/docs/analytics/repzoql/functions)
- [Objects](https://workstation.repzo.com/docs/analytics/repzoql/objects)
