mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-16 04:32:33 +00:00
c23c7e0b6f
* feat: add DDSketch quantile * Fix StyleCheck * Move quantileddsketch.md under right dir * Update stateless test number and add stateful test * Throw exception when relative accuracy is too low * Update test number * Fix undefined behaviour for empty store * Fix quantileGK test * Update test numbers * Update src/AggregateFunctions/ * Throw exception on out of range values * Update relative accuracy docs and add encoding details * Address review comments and suggestions * Remove unused function * Address alexey review comments * Remove unused function isFloat64FieldType * Throw error on invalid relative accuracy * Simplify mapping * Address remaining review comments * Add effective memory usage suggestions * Fix Stylecheck * Fix fast test * Incorporate bins capacity suggestion * Fix fuzzer * Remove inheritance in Mapping, Store and DDSketch * Add checks for bin resizing * Add note about the binary compatible implementation
49 lines
2.1 KiB
Markdown
49 lines
2.1 KiB
Markdown
---
|
|
slug: /en/sql-reference/aggregate-functions/reference/median
|
|
sidebar_position: 212
|
|
---
|
|
|
|
# median
|
|
|
|
The `median*` functions are the aliases for the corresponding `quantile*` functions. They calculate median of a numeric data sample.
|
|
|
|
Functions:
|
|
|
|
- `median` — Alias for [quantile](../../../sql-reference/aggregate-functions/reference/quantile.md#quantile).
|
|
- `medianDeterministic` — Alias for [quantileDeterministic](../../../sql-reference/aggregate-functions/reference/quantiledeterministic.md#quantiledeterministic).
|
|
- `medianExact` — Alias for [quantileExact](../../../sql-reference/aggregate-functions/reference/quantileexact.md#quantileexact).
|
|
- `medianExactWeighted` — Alias for [quantileExactWeighted](../../../sql-reference/aggregate-functions/reference/quantileexactweighted.md#quantileexactweighted).
|
|
- `medianTiming` — Alias for [quantileTiming](../../../sql-reference/aggregate-functions/reference/quantiletiming.md#quantiletiming).
|
|
- `medianTimingWeighted` — Alias for [quantileTimingWeighted](../../../sql-reference/aggregate-functions/reference/quantiletimingweighted.md#quantiletimingweighted).
|
|
- `medianTDigest` — Alias for [quantileTDigest](../../../sql-reference/aggregate-functions/reference/quantiletdigest.md#quantiletdigest).
|
|
- `medianTDigestWeighted` — Alias for [quantileTDigestWeighted](../../../sql-reference/aggregate-functions/reference/quantiletdigestweighted.md#quantiletdigestweighted).
|
|
- `medianBFloat16` — Alias for [quantileBFloat16](../../../sql-reference/aggregate-functions/reference/quantilebfloat16.md#quantilebfloat16).
|
|
- `medianDDSketch` — Alias for [quantileDDSketch](../../../sql-reference/aggregate-functions/reference/quantileddsketch.md#quantileddsketch).
|
|
|
|
**Example**
|
|
|
|
Input table:
|
|
|
|
``` text
|
|
┌─val─┐
|
|
│ 1 │
|
|
│ 1 │
|
|
│ 2 │
|
|
│ 3 │
|
|
└─────┘
|
|
```
|
|
|
|
Query:
|
|
|
|
``` sql
|
|
SELECT medianDeterministic(val, 1) FROM t;
|
|
```
|
|
|
|
Result:
|
|
|
|
``` text
|
|
┌─medianDeterministic(val, 1)─┐
|
|
│ 1.5 │
|
|
└─────────────────────────────┘
|
|
```
|