# Functions

> How NYXDB functions are catalogued, referenced and bound, with casts and aggregates.

## The catalog and the reference

The [function reference](/docs/functions) is generated from the function
catalog: one page per family, one entry per function, each with its
signatures, behaviour and an example.

## Functions in SQL

The library spans aggregate, date and time, math, string, conversion,
conditional, JSON, array, map, hash, encoding, URL, IP, geospatial and
statistical families. Aggregates include `COUNT`, `SUM`, `MIN`, `MAX`, `AVG`,
`count_distinct` (also `COUNT(DISTINCT …)`, `uniq` and `uniq_exact`), `median`
and `quantile`, and arithmetic over aggregate calls forms one output, for
example `SUM(amount * price_usd) / SUM(amount)`. Casts are written
`CAST(x AS T)`, `TRY_CAST(x AS T)` or `x::T`; a checked cast raises an error for
a value that does not fit, and `TRY_CAST` yields NULL instead. Searched and
simple `CASE … END` and window functions with `OVER` are part of the grammar,
and `TUMBLE`, `HOP` and `SESSION` windows group [streaming](/docs/sql/streaming)
queries.

## Exact distinct counts

`uniq` and `uniq_exact` are aliases of `count_distinct`, and all three are
exact. NULL values are not counted.

```sql
SELECT token, uniq(recipient) AS recipients
FROM transfers
GROUP BY token
```

## Discovering functions

`SHOW FUNCTIONS` lists the functions of the node, and the generated reference
documents each one:

- [Function reference](https://nyxdb.io/docs/functions/) — Every function family with its signatures, behaviour and an example.

## Binding

A call is bound by name and argument types to one exact function revision, and
the bound identity is stored with a definition, so a stored plan never
re-resolves a function by its text. Function names are
case-insensitive.

---

Source: https://nyxdb.io/docs/sql/functions/
