gpt4 book ai didi

postgresql - postgres : Combining filter() with a percentile_cont()

转载 作者:行者123 更新时间:2023-12-04 01:50:21 24 4
gpt4 key购买 nike

尝试使用 filter()调用 percentile_const 中的条款我不确定我能做到这一点。有办法吗?这是示例查询:

select
count(*) as n1,
count(*) filter(where ha >= 0) as n2,
percentile_cont(.9) within group (order by es asc) as p1,
percentile_cont(.9) filter (where ha >= 0) within group (order by es asc) as p2
from mytable where mypid = 123;

在没有 p2 的情况下,查询工作正常当然打电话,但你可以看到我想做什么。

最佳答案

filter需要去追 within group部分:

select
count(*) as n1,
count(*) filter(where ha >= 0) as n2,
percentile_cont(.9) within group (order by es asc) as p1,
percentile_cont(.9) within group (order by es asc) filter (where ha >= 0) as p2
from mytable
where mypid = 123;

关于postgresql - postgres : Combining filter() with a percentile_cont(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53381325/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com