ReferenceApplies to: Unified engine deployments
SELECT returns expressions from a source. A source can be a table, view, subquery, inline VALUES relation, or a supported table function. A SELECT without FROM evaluates scalar expressions once.
Syntax
The common clause order is:
WHERE filters input rows. GROUP BY forms groups; HAVING filters those groups. Window expressions retain individual rows. ORDER BY determines result order; LIMIT restricts returned rows.
Projection and aliases
Select named columns to keep the result focused. * selects all visible columns; alias.* selects columns from one source. Give calculated outputs explicit names.
Filtering
Combine predicates with AND, OR, and NOT. Parenthesize mixed logic. A WHERE predicate retains only rows for which its result is TRUE; FALSE and NULL are excluded.
DISTINCT
DISTINCT removes duplicate complete projected rows. It applies to the whole projection, not just the first column. DISTINCT ON is unavailable.
Ordering, limits, and offsets
Ascending order is the default. State NULLS FIRST or NULLS LAST when null placement matters. Add a unique tie-breaker for repeatable limited results. Without ORDER BY, a returned row order is not guaranteed. LIMIT controls returned rows and does not guarantee that the engine reads only that many source rows.
SORT BY, DISTRIBUTE BY, and CLUSTER BY have dialect-specific planning behavior. Use ORDER BY when the result must have a defined global order. QUALIFY, TOP, FETCH, SELECT INTO, and LIMIT BY are unavailable.Last modified on November 4, 2026