Count
Builds a count(*) expression, usable anywhere an SQL element is accepted (typically as a
Select column).
Constructor
Count(): Count
new Count(): Count
Dual-callable, no arguments — Count always counts rows (count(*)); it does not accept a column
expression to count distinct/non-null values of.
import { Count, Select } from '@sqb/builder';
Select('country', Count().as('total')).from('customers').groupBy('country');
// select country, count(*) total from customers group by country
Properties
| Key | Type | Readonly | Description |
|---|---|---|---|
_type | SerializationType.COUNT_STATEMENT | Yes | Discriminates this node during serialization. |
_alias | string | undefined | No | Set by .as(). |
Methods
as()
as(alias: string): this
Sets an alias, rendered as a trailing alias after the closing paren (no AS keyword).
Count().as('total');
// count(*) total