Doing math with fields values does not show decimals


I am trying to calculate a percentage from two fields which in real life calculator gives a value of 0.332 but using sql queries I am only getting "0" therefore while multiplying with 100 instead of getting 33.2 I am getting 0. Any way I can force it to show the decimals?

Hi @zozo6015,
Can you mention the ES version you tested this on and the actual query, please?


I was using elasticsearch 6.6.0.

I came up with this query to convert the INT to FLOAT type and then the result would be the expected.

SELECT TRUNCATE(CAST( AS float)/CAST( AS float), 4) AS Free_percentage from "metricbeat-6.5.1-*"  WHERE IS NOT null ORDER BY "@timestamp" LIMIT 1

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.