This is probably my own SQL rustiness, but can someone explain this to me?
If I run this query:
SELECT d.name, disks.name, free_space/size FROM devices d LEFT OUTER
JOIN disks ON (d.id=disks.computer_id AND disks.name='G:') WHERE
d.name='kensho' ;
I get the following result:
kensho|G:|0.869779988128673
If I run this query:
SELECT d.name, disks.name, SUM(free_space)/SUM(size) FROM devices d LEFT
OUTER JOIN disks ON(d.id=disks.computer_id AND disks.name='G:') WHERE
d.name='kensho' ;
I get the following result:
kensho|G:|0
The only difference between the 2 queries is that I am returning
SUM(free_space)/SUM(size) in the second one, istead of just free_space/size.
Why is trying to sum the results when there is a single row resulting in
0? Is there just some weird SQL syntax that I am forgetting?