Title
#sql
Andreas Piening

Andreas Piening

05/30/2022, 2:29 PM
I’m using the
ROUND
statement in some queries where I need to calculate the percentage. For example
SELECT path, type, ROUND((blocks_available * blocks_size * 10e-10), 2) AS free_gb, ROUND ((blocks_available * 1.0 / blocks * 1.0) * 100, 2) AS free_perc FROM mounts WHERE path = '/';
I expect the percentage to have
two digits
after the decimal point, but instead I get values like
51.020000000000003
. Can anyone tell why this is or how I can fix this? These long numbers are hard to read for percentage values.