douglas_forsell douglas_forsell - 1 year ago 104
SQL Question

PostgreSQL treating the same values as different

So in this example the SQL is returning a row that has the columns "quantidade" and "quantidade_reservada", each containing the value "110", type double precision:


When I try to apply a condition to retrieve only results where "quantidade" is not equal to "quantidade_reservada", PostgreSQL does not seem to differentiate the numbers.

How is 110 different from 110?

Answer Source

Floating-Point Types:

The data types real and double precision are inexact, variable-precision numeric types.


where round(quantidade::numeric, 2) != round(quantidade_reservada::numeric, 2)

Arbitrary Precision Numbers

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download