Function build

Source
fn build(agg: &AggCall) -> Result<BoxedAggregateFunction>
Expand description

Computes the discrete percentile, the first value within the ordered set of aggregated argument values whose position in the ordering equals or exceeds the specified fraction. The aggregated argument must be of a sortable type.

statement ok
create table t(x int, y bigint, z real, w double, v varchar);

statement ok
insert into t values(1,10,100,1000,'10000'),(2,20,200,2000,'20000'),(3,30,300,3000,'30000');

query R
select percentile_disc(0) within group (order by x) from t;
----
1

query R
select percentile_disc(0.33) within group (order by y) from t;
----
10

query R
select percentile_disc(0.34) within group (order by z) from t;
----
200

query R
select percentile_disc(0.67) within group (order by w) from t
----
3000

query R
select percentile_disc(1) within group (order by v) from t;
----
30000

query R
select percentile_disc(NULL) within group (order by w) from t;
----
NULL

statement ok
drop table t;