Monday, 29 February 2016

Re: [firebird-support] SUM(DC.I) / SUM(DC.Q) vs SUM(DC.I / DC.Q) why result is different?

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



------------------------------------

------------------------------------

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Visit http://www.firebirdsql.org and click the Documentation item
on the main (top) menu. Try FAQ and other links from the left-side menu there.

Also search the knowledgebases at http://www.ibphoenix.com/resources/documents/

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
------------------------------------

Yahoo Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-digest@yahoogroups.com
firebird-support-fullfeatured@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-unsubscribe@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/

No comments:

Post a Comment