问题描述
我无法使用 percentile_cont 计算运行中位数和百分位数,主要是因为 Postgres 不允许您在其中使用 Windows 函数或 Partition By。
此处的数据使用的是运行平均值(用于演示目的)
所以我的数据需要按年份和城市分组,并将运行中位数/运行百分位数列附加到每一行。
from table1
join
(select year,city,percentile_cont(0.25) within group (order by a),percentile_cont(0.50) within group (order by a) as p_median
from table1
group by year,dt
)d2
on d2.year=d.year and d2.city=d.city
(抱歉,无法弄清楚如何在没有 点击)。
https://i.stack.imgur.com/ZkLUc.png
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)