Query syntax
The parts of a query, in the order you write them.
| Name | What it does |
|---|---|
| SELECT | Read rows from the model, landed tables, datasets, extracted entities and views. |
| WITH | Name a query step once and read it by name; walk a hierarchy with WITH RECURSIVE. |
| FROM | Name the table a SELECT reads. |
| JOIN | Combine rows from two tables. |
| VIA | Join along a declared link, or on the same person, without writing the join keys. |
| AS OF | Read a dataset table as it was at a past time. |
| WHERE | Keep only the rows that meet a condition. |
| GROUP BY | Collapse rows that share values into one row per group. |
| HAVING | Keep only the groups that meet a condition. |
| OVER | The window a window function reads: its partition, order and frame. |
| UNION, INTERSECT, EXCEPT | Combine the rows of two SELECTs. |
| ORDER BY | Sort the result rows. |
| LIMIT | Return at most a number of rows, optionally after skipping some. |
| DISTINCT | Remove duplicate result rows. |
| Subqueries | A SELECT inside another, as a derived table or in a WHERE condition. |