Amazon Athena 中窗口函数中的百分位数

问题描述 投票:0回答:1

我正在寻找问题的解决方案。我正在使用 Amazon Athena,需要一个字段来显示产品在 2 个时间戳之间的天数百分位。我让它在 Amazon Quicksight 中工作,但由于那里聚合的限制,我无法在其他计算字段中使用结果。所以我唯一的选择是将该字段作为 SQL 语句直接构建到我的数据集中。但当我尝试构建它时,它总是给我错误。

我尝试了以下陈述:

approx_percentile(case when (date_diff('millisecond', b.zp8_ts,b.depein_ts) / (1E3 *3600 *24)<0)OR (date_diff('millisecond', b.zp8_ts,b.depein_ts) / (1E3 *3600 *24) >200) then null else date_diff('millisecond', b.zp8_ts,b.depein_ts) / (1E3 *3600 *24)end,20) OVER (werkziel) 

case when (date_diff('millisecond', b.vhfein_ts,b.vhfaus_ts) / (1E3 *3600 *24)<0)OR (date_diff('millisecond', b.vhfein_ts,b.vhfaus_ts) / (1E3 *3600 *24) >200) then null else Percentile_count(date_diff('millisecond', b.vhfein_ts,b.vhfaus_ts) / (1E3 *3600 *24)) OVER (PARTITION BY concat(c.pk_nr_werk_num2,c.zielort_id),20) end 

这是来自 Amazon Quicksight 的计算字段,正在运行:percentileCont({zp8_depein_90},20,[werkziel])

样本数据: enter image description here

zp8_ts 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 2022年1月1日 德佩因_ts 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 2022年1月5日 pk_num_werk_num2 05 05 05 05 05 05 05 05 05 05 05 05 05 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 zielort_id ABC08L ABC44L ABC08L ABC44L ABC08L ABC44L ABC08L ABC44L ABC08L ABC44L ABC08L ABC44L ABC08L ABC44L ABC08L ABC44L ABC08L ABC44L ABC08L ABC44L ABC08L ABC44L ABC08L ABC44L ABC08L ABC44L ABC08L ABC44L ABC08L ABC44L ABC08L ABC44L ABC08L ABC44L ABC08L ABC44L ABC08L ABC44L ABC08L ABC44L ABC08L ABC44L ABC08L ABC44L ABC08 L

sql window-functions amazon-athena percentile-cont
1个回答
0
投票

我已经找到了解决这个问题的方法。比赛结束后出现缺席的情况。

approx_percentile(情况当(date_diff('毫秒',b.vhfaus_ts,b.depein_ts)/(1E3 * 3600 * 24)<0)OR (date_diff('millisecond', b.vhfaus_ts,b.depein_ts) / (1E3 *3600 *24) >200)然后为空其他date_diff('毫秒',b.vhfaus_ts,b.depein_ts)/( 1E3 *3600 *24)end,0.8) OVER (分区 by concat(c.pk_nr_werk_num2,c.zielort_id)) AS vhfaus_depein_p80,

© www.soinside.com 2019 - 2024. All rights reserved.