首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >标准差预置

标准差预置
EN

Stack Overflow用户
提问于 2021-12-06 15:29:15
回答 1查看 1.6K关注 0票数 0

我想计算一下avg_total_orders_last_30_days using the avg_total_orders_last_12_months的标准差。

样本表

代码语言:javascript
复制
customer_id | avg_total_orders_last_30_days | avg_total_orders_last_12_months

939           103                             94
441           107                             118
082           313                             293

这就是我迄今尝试过的:

代码语言:javascript
复制
select 
    customer_id
    avg_total_orders_last_30_days,
    avg_total_orders_last_12_months,
    approx_distinct(SUM(avg_total_orders_last_12_months)) OVER (partition by customer_id ) as stdev_rep
from table
group by 1
EN

回答 1

Stack Overflow用户

发布于 2021-12-09 07:51:14

我认为这就是您想要做的,但是您的avg_total_orders_last_12_months字段包含的数字太大,不能用作approx_distinct的“e”。

接近不同的链接

approx_distinct(x,e)→bigint#

返回不同输入值的近似数目。这个函数提供了计数的近似(不同的x)。如果所有输入值为空,则返回零。此函数应产生不超过e的标准误差,这是所有可能集上(近似正态分布)误差分布的标准差。它不保证对任何特定输入集的错误都有上限。这个函数的当前实现需要在0.0040625,0.26000__的范围内。

如果您希望获得字段的真正样本标准差,请使用STDDEV(x),如下所示:

标准差链

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70247894

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档