Skip to main content
awhitter
Gold ⭐️
Jun 11, 2017 4:50 PM UTC

SQL arithmetic operations return the wrong value in Phoenix

  • Oct 5, 2026 9:22 AM UTC
  • 0 replies
  • 995 views
  • Translate All

Problem: Certain arithmetic operations return the wrong result in Phoenix.

For example:

0: jdbc:phoenix:> select 2/4 ;
+----+
| 0 |
+----+
| 0 |
+----+
1 row selected (0.014 seconds)

Cause: This is because the result is returned as an int rather than a decimal

See PHOENIX-3312

Workaround: Provide decimal values within the SQL

e.g.

0: jdbc:phoenix:> select 2.0/4.0 ;
+------+
| 0.5 |
+------+
| 0.5 |
+------+
1 row selected (0.011 seconds)