sql - Presto - 插入数组作为函数输入

标签 sql group-by presto

根据 Presto Documentation :

approx_percentile(x, percentages) → array<[same as x]>
Returns the approximate percentile for all input values of x at each of the specified percentages. Each element of the percentages array must be between zero and one, and the array must be constant for all input rows.


我想在第 25 个、第 50 个、第 75 个和第 95 个百分位数处找到 amount 的关联值,假设输出是一个数组,但无法弄清楚如何将这些值提供给函数 < em>(除了提供一个值)。

我已经尝试了我习惯看到的各种表示,但我一直返回错误。如何输入多个值得到数组输出?

APPROX_PERCENTILE(amount, .25, .50, .75, .95)

APPROX_PERCENTILE(amount, (.25, .50, .75, .95))

APPROX_PERCENTILE(amount, {.25, .50, .75, .95})

APPROX_PERCENTILE(amount, [.25, .50, .75, .95])   '<--- I assumed this was the proper way

APPROX_PERCENTILE(amount, <[.25, .50, .75, .95]>)

APPROX_PERCENTILE(amount, <.25, .50, .75, .95>)

最佳答案

刚弄明白 - 输入数组作为函数参数的正确方法是:

APPROX_PERCENTILE(amount, ARRAY[0.25, 0.50, 0.75, 0.95])

关于sql - Presto - 插入数组作为函数输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61217867/

相关文章:

python - 使用 groupby 获取组中具有最大值的行

python - Spark MinMaxScaler 在数据帧上

sql - 递归跟踪状态数量未知的客户状态(Presto SQL)

mysql - 无法在 WHERE 子句中使用 MySQL extract() 函数

c# - 使用 SqlFileStream 从 WCF 服务返回流

mysql - 使用 ROLLUP 后尝试对查询进行排序

sql - 如何从带有时间戳 (6) 的 Oracle 表中进行选择?

r - data.table 不计算 NA 组 by

sql - 使用 PrestoSQL 进行 32 位或 64 位浮点除法