# quantileBFloat16 (/docs/reference/sql/aggregate-functions/quantilebfloat16)



This page describes the RawTree engine binary used to generate this reference. It does not define Query API support. Descriptions retain upstream ClickHouse terminology. See [SQL interface scope](/docs/reference/clickhouse-compatibility#service-interfaces).

Computes an approximate [quantile](https://en.wikipedia.org/wiki/Quantile) of a sample consisting of [bfloat16](https://en.wikipedia.org/wiki/Bfloat16_floating-point_format) numbers.

`bfloat16` is a floating-point data type with 1 sign bit, 8 exponent bits and 7 fraction bits.
The function converts input values to 32-bit floats and takes the most significant 16 bits. Then it calculates `bfloat16` quantile value and converts the result to a 64-bit float by appending zero bits.
The function is a fast quantile estimator with a maximum relative error of `0.78125%` (and an average relative error of approximately `0.27%`), corresponding to the 7-bit mantissa precision of `bfloat16`.

**Syntax**

```sql
quantileBFloat16[(level)](expr)
```

**Parameters**

* `level` — Optional. Level of quantile. Possible values are in the range from 0 to 1. Default value: 0.5. [`Float*`](/reference/data-types/float)

**Arguments**

* `expr` — Expression over the column values resulting in numeric data types, `Date` or `DateTime`. [`(U)Int*`](/reference/data-types/int-uint) or [`Float*`](/reference/data-types/float) or [`Date`](/reference/data-types/date) or [`DateTime`](/reference/data-types/datetime)

**Returned value**

Approximate quantile of the specified level. For `Date` and `DateTime` inputs the output format matches the input format. [`Float64`](/reference/data-types/float) or [`Date`](/reference/data-types/date) or [`DateTime`](/reference/data-types/datetime)

**Examples**

**Computing quantile with bfloat16**

```sql title=Query
CREATE TABLE example_table (a UInt32, b Float32) ENGINE = Memory;
INSERT INTO example_table VALUES (1, 1.001), (2, 1.002), (3, 1.003), (4, 1.004);

SELECT quantileBFloat16(0.75)(a), quantileBFloat16(0.75)(b) FROM example_table;
```

```text title=Response
┌─quantileBFloat16(0.75)(a)─┬─quantileBFloat16(0.75)(b)─┐
│                         3 │                         1 │
└───────────────────────────┴───────────────────────────┘
```

*Introduced in version 21.7.0.*
