2

I have the following table items. which looks like this

|    date    |  id |   s_px   |   c_px   | fee |
+------------+-----+----------+----------+-----+
| 2015-01-01 | 001 | 5355.00  |  5355.00 |   2 |
| 2015-01-01 | 002 | 13240.00 | 13240.00 |   3 |
| 2015-01-01 | 003 | 5840.00  |  5840.00 |   1 |
| 2015-01-01 | 004 | 20.55    |    20.59 |   5 |
| 2015-01-01 | 005 | 64.42    |    64.42 |   6 |

column s_px and c_px had data type pf float8

when I do the compare s_px and c_px for unequality

select * from items where s_px != c_px

This returns almost the same original table. I know direct float compare is not easy. But is there any thing similar to numpy.isclose

2
  • floating-point-gui.de Commented Aug 14, 2018 at 19:09
  • @a_horse_with_no_name thanks for the link Commented Aug 15, 2018 at 22:10

1 Answer 1

6

The inequality operator is <> (or !=), so your query is correct. However, floating point values are fickle. I would suggest checking to be sure they are not within some small range of each other:

select *
from items
where abs(s_px - c_px) > 0.0001;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.