0

我正在计算跨列的 13 周值的总和,如下所示,就像我希望计算中位数一样,有人可以帮助我吗?谢谢!

select a.prod_name,a.week_date,a."13week_sum",
COALESCE(CASE WHEN COUNT(*) over (partition by prod_name order by prod_name,week_date desc rows between 0 preceding and 12 following) = 13 then 
sum(a."value") over (partition by prod_name order by prod_name,week_date desc rows between 0 preceding and 12 following)
end)
as "13week_sum"
from vin_table_temp a order by week_date

我正在使用带有 8.2 版 postgres 的青梅。

4

0 回答 0