【发布时间】:2020-11-26 02:57:27
【问题描述】:
给定一个表格,我需要计算 25% 和 75% 四分位数的四分位数范围——它应该只是一个输出差值。
注意:'gini' 只是我的表 rdata 中的一列;由于数据很长,我这里就不输入数据了,但我只需要弄清楚如何通过 percentile_disc/cont 输出差异。
select percentile_disc(0.75)-percentile_disc(0.25) within group (order by gini) from rdata;
输出错误:
LINE 1: select percentile_disc(0.75)-percentile_disc(0.25) within gr...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts..
我尝试转换 percentile_disc::numeric 但这也给了我一个错误。
【问题讨论】:
-
你需要函数 percentile_disc 错误信息说得很清楚
-
你使用的是 MySQL 还是 Postgresql?
-
@jarlh:从错误消息来看,这是 Postgres。我删除了 MySQL 标签。
标签: sql postgresql group-by percentile