数据仓库服务 GAUSSDB(DWS)-聚集函数:percentile_disc(const) within group(order by expression)

时间:2024-12-06 15:12:39

percentile_disc(const) within group(order by expression)

描述:返回第一个在排序中位置等于或者超过指定分数的输入值。

输入:const为在0-1之间的数值,expression当前只支持数值类型和interval类型。其中空值不参与计算。

返回类型:对于任何整型数据输入,结果都是NUMERIC类型。否则,与输入数据类型相同。

示例:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
SELECT percentile_disc(0.3) within group(order by x) FROM (SELECT generate_series(1,5) AS x) AS t;
percentile_disc
-----------------
2
(1 row)
SELECT percentile_disc(0.3) within group(order by x desc) FROM (SELECT generate_series(1,5) AS x) AS t;
percentile_disc
-----------------
4
(1 row)
support.huaweicloud.com/sqlreference-910-dws/dws_06_0046.html