1

I am new to HANA, and was trying to write a SQL for finding standard deviation: select stddev(values) as stddev For example, the values are 6.8,10.2 and 3.4. When I am executing it in HANA, I am getting result as 3.39999. But when I try to calculate it manually, or by excel, it shows 3.4.

Similarly, for different example, I get 5.1999 in HANA, but in excel/manual check it shows 5.2.

What can be the reason/fix for this?

Ayn76
  • 21
  • 4

1 Answers1

1

Based on the result, I'd guess that this query is using a floating point numeric data type (REAL, FLOAT, DOUBLE).

Try using a fixed point numeric data type instead, say DECIMAL (10, 3).


After checking with a HANA 2.00.54 version, I can confirm this solution. With this version of HANA, the calculation is correctly performed with DOUBLE precision and the result is 3.4 without any change.

When explicitly casting both the input data and the stddev function using TO_REAL the reported approximated result of 3.3999... is returned.


Lars Br.
  • 9,949
  • 2
  • 15
  • 29