Skip to main content

Query syntax

The parts of a query, in the order you write them.

NameWhat it does
SELECTRead rows from the model, landed tables, datasets, extracted entities and views.
WITHName a query step once and read it by name; walk a hierarchy with WITH RECURSIVE.
FROMName the table a SELECT reads.
JOINCombine rows from two tables.
VIAJoin along a declared link, or on the same person, without writing the join keys.
AS OFRead a dataset table as it was at a past time.
WHEREKeep only the rows that meet a condition.
GROUP BYCollapse rows that share values into one row per group.
HAVINGKeep only the groups that meet a condition.
OVERThe window a window function reads: its partition, order and frame.
UNION, INTERSECT, EXCEPTCombine the rows of two SELECTs.
ORDER BYSort the result rows.
LIMITReturn at most a number of rows, optionally after skipping some.
DISTINCTRemove duplicate result rows.
SubqueriesA SELECT inside another, as a derived table or in a WHERE condition.