-1

How to get query result when using "floating-point type parameter equals to certain number" in Apache IoTDB? When I query data in Apache IoTDB, I realized that if the parameter is a floating-point type, when using "where parameter = XX" statement, no result can be found. However I know that there should be data that equals XX. How to solve this problem?

Eric Postpischil
  • 195,579
  • 13
  • 168
  • 312
  • How do you know there should be data that equals XX? Is the number in the database actually, for example, 3.00000034… but looks like 3.000000 because the software formatting it for display shows only “3.000000”? So querying for 3.000000 does not work because it does not equal the actual number in the database? If the numbers are the results of arithmetic calculations in floating-point, you generally should expect they contain various rounding errors and should not try to match them by exact equality. Why are you trying to find records by floating-point values? – Eric Postpischil Jun 29 '23 at 10:11

1 Answers1

0

In sql statement, not all floating-point values can be saved with accurate precision, so if you use = function, you may not be able to match the qualified data in Apache IoTDB. You can try the following: SELECT RecordTime FROM test WHERE ABS(parameter- XX) < 1e-5, which is to use absolute value to query float type values that are equal to your requirement.

Xinyu Tan
  • 81
  • 1