Subject Re: [firebird-support] SUM(DC.I) / SUM(DC.Q) vs SUM(DC.I / DC.Q) why result is different?
Author Fernando P. Nájera Cano
Hi Luigi,

> I not understand,

> I have this table (DC):

> A_ID I Q
> 1 370 1
> 2 370 1

> sum(DC.I) is = 740
> and sum(DC.Q) is = 2
> then 740/2 = 370

> but
> SUM(DC.I / DC.Q) it should be (740 / 2) = 370. Why not?

> Why i am wrong?

When you do SUM(DC.I / DC.Q), the value of the division is calculated
*per row*, and then those values are summed up.

So, you are doing this (see the last column):

> A_ID I Q I/Q
> 1 370 1 370/1=370
> 2 370 1 370/1=370

And therefore, SUM(I/Q) = 370+370 = 740

Best regards,

Fernando Nájera