我正在使用 psql (9.1.3)。我有一张 table (比如说)A
A 有两列:
a_id:整数
customer_pay: double
I have these values in the table.
a_id | customer_pay |
--------------------+--------------+
1733684 | -264.6 | 1723382 | -314.84 | 1728106 | 50.55 | 1741636 | -264.6 | (4 rows)
但是当我这么做的时候
select a_id from A where customer_pay = -264.6;
我什么也没有。
我尝试了所有可能的精度变化,例如 -264.60、-264.00 等。 此查询对于 +264.6 准确有效。 我应该如何选择负 double 类型的值。
感谢您的帮助。
最佳答案
select a_id
from a
where round(customer_pay::numeric, 2) = -264.6
Calculations with numeric values yield exact results where possible, e.g. addition, subtraction, multiplication. However, calculations on numeric values are very slow compared to the integer types, or to the floating-point types described in the next section.
关于mysql - postgres 查询不匹配负 double 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40399476/