计算 AWS Athena 中每个组的中位数 table
Calculate Median for each group in AWS Athena table
以下是雅典娜的架构 table
我希望按 standard_lab_parameter_name 和单位计算 'parameter_value' 组的中位数。为此,我遵循了 link : https://docs.aws.amazon.com/redshift/latest/dg/r_MEDIAN.html
但是在 运行 查询
select median(parameter_value) from table_name group by standard_lab_parameter_name, units
它抛出错误
SYNTAX_ERROR: line 1:8: Function median not registered
有什么帮助吗?或者,如果一些替代查询会很棒
Athena 基于 Presto 0.172 - 您可以在 AWS DML Queries, Functions, and Operators. I guess you could use approx_percentile(x, percentage)
or approx_percentile(x, w, percentage, accuracy)
, see Presto Aggregate Functions:
中查看所有支持的功能
Returns the approximate percentile for all input values of x at the given percentage. The value of percentage must be between zero and one and must be constant for all input rows.
select approx_percentile(parameter_value,0.5)
from table_name
group by standard_lab_parameter_name, units
请记住,这是一个近似聚合函数。
以下是雅典娜的架构 table
我希望按 standard_lab_parameter_name 和单位计算 'parameter_value' 组的中位数。为此,我遵循了 link : https://docs.aws.amazon.com/redshift/latest/dg/r_MEDIAN.html 但是在 运行 查询
select median(parameter_value) from table_name group by standard_lab_parameter_name, units
它抛出错误
SYNTAX_ERROR: line 1:8: Function median not registered
有什么帮助吗?或者,如果一些替代查询会很棒
Athena 基于 Presto 0.172 - 您可以在 AWS DML Queries, Functions, and Operators. I guess you could use approx_percentile(x, percentage)
or approx_percentile(x, w, percentage, accuracy)
, see Presto Aggregate Functions:
Returns the approximate percentile for all input values of x at the given percentage. The value of percentage must be between zero and one and must be constant for all input rows.
select approx_percentile(parameter_value,0.5)
from table_name
group by standard_lab_parameter_name, units
请记住,这是一个近似聚合函数。