I’ve got a simple subquery that calculates the latest free space % on a disk for the given time window
SELECT
last("available_space") / last("total_space") AS "Free Space %"
FROM "rp"."volume_space"
WHERE time >= now() - 1h
GROUP BY
"server"
,"volume"
The source values are integers, the result of division is a decimal number (between 0 and 1)
So far so good, the returned value look like those:
sever | volume | Free Space %
Server1 | C | 0.5622
Server1 | D | 0.2608
Server2 | C | 0.8465
Server2 | D | 0.9100
now, I need to get the worst case per server, just the “Free Space %” and “server”.
so I just add a simple min
over the previous result
SELECT
min("Free Space %") AS "Least Free Space %"
FROM (
SELECT
last("available_space") / last("total_space") AS "Free Space %"
FROM "rp"."volume_space"
WHERE time >= now() - 1h
GROUP BY
"server"
,"volume"
)
GROUP BY
"server"
Now all the returned value are 0
source:
Server1 | C | 0.5622
Server1 | D | 0.2608
Server2 | C | 0.8465
Server2 | D | 0.9100
expected result
Server1 | 0.2608
Server2 | 0.8465
actual result
Server1 | 0
Server2 | 0
to avoid having just zeroes, I’ve multiplied the first result by 100, so I get numbers in a range 0-100 (instead of 0-1). what I can say is that the decimal part gets truncated.
26.08
becomes just 26
is this the standard behavior?
Am I missing something?