Returns the median calculated from values of a group.
Requires: SQL warehouse version 2022.35 or higher. This version is available in the Preview channel.
expr: An expression that evaluates to a numeric or an interval.
cond: An optional boolean expression filtering the rows used for aggregation.
The following explains how the result types are computed:
year-month interval: The result is an
INTERVAL YEAR TO MONTH.
day-time interval: The result is an
INTERVAL DAY TO SECOND.
In all other cases the result is a DOUBLE.
Nulls within the group are ignored. If a group is empty or consists only of nulls, the result is
DISTINCT is specified, duplicates are removed and the median is computed.
This function is a synonym for percentile_cont(0.5) WITHIN GROUP (ORDER BY expr).