cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

How to change rounding in cypher query

fhol
Node Link

I've the following in a query:

RETURN (3/5)*100 as total

current output: 0

desired output: 0.6

The problem is that it rounds decimal numbers to the lowest integer, so this way I can never compute a percentage. Does anyone know how to change this?

1 ACCEPTED SOLUTION

Hello @fhol

There are several ways:

RETURN (3.0 / 5.0) * 100 AS total
RETURN (toFloat(3) / toFloat(5)) * 100 AS total

Regards,
Cobra

View solution in original post

3 REPLIES 3

Hello @fhol

There are several ways:

RETURN (3.0 / 5.0) * 100 AS total
RETURN (toFloat(3) / toFloat(5)) * 100 AS total

Regards,
Cobra

@Cobra Such a newbie question but really helpful for a beginner, thanks!

No problem, I'm happy to help, there are no bad questions