final class DistinctClause
    implements Node
    uses Snapshot
Public API: explicitly declared with @visibility public.

DISTINCT or DISTINCT ON: which rows of a selection are kept when they repeat.

Mirrors the distinctClause of PostgreSQL's SelectStmt: an empty list for DISTINCT, the expressions for DISTINCT ON. The DISTINCT ON expressions are interpreted with the rules of ORDER BY; the selection that holds the clause derives them. Source: https://www.postgresql.org/docs/17/sql-select.html#SQL-DISTINCT.

Reading a DISTINCT ON clausedoctest
$query = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('SELECT DISTINCT ON (1) 1, 2');
    count($query->statement->distinct->on) // => 1

Properties§

public list<Scalar> $on

Methods§

public function __construct(list<Scalar> $on = [])

Parameters

$onlist<Scalar>The DISTINCT ON expressions; empty for plain DISTINCT
Calls 2
public function render(Output $out): void

Writes DISTINCT and the parenthesized DISTINCT ON expressions.

Parameters

$outOutput
Calls 1

Test cases 1§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 1

Relations§

Instantiated in 2
Type declarations 3