如何比较双精度数组

时间:2019-07-11 16:08:12

标签: postgresql

仅想比较双精度列值,这些值将返回也是双精度的结果。

使用PostgreSQL 9.6,我还没有找到一种比较浮点数或数字数据类型的数组而不将其转换为整数的方法。

select * from 
(
    select  
        t1."SubdSec-in-DCA_id",
        t1."float_range" as left_side,
        t2."float_range" as right_side,
        t1."float_range"::numeric[] - t2."float_range"::numeric[] as results
    from "TEST" t1
    cross join lateral (select  "float_range" from "TEST") t2
) t3
order by "SubdSec-in-DCA_id",left_side, right_side

t1."float_range"::int[] & t2."float_range"::int[] as results, 的作品:但返回值作为整数 结果:"T_S07414_DCA4117","{197.598,205.382}","{146.5,146.9}","{198,205}"

t1."float_range"::float[] & t2."float_range"::float[] as results, 失败:ERROR: operator does not exist: double precision[] & double precision[]

t1."float_range"::numeric[] & t2."float_range"::numeric[] as results 失败:ERROR: operator does not exist: numeric[] & numeric[]

0 个答案:

没有答案