[EMAIL PROTECTED] wrote:

Michael Stassen wrote:


EXP(SUM(LOG(COALESCE(*the field you want to multiply*,1)))

which works because LOG(xy) = LOG(x) + LOG(y), and EXP(LOG(x)) = x. Hence, sum of the logs = log of the product, so exp of the sum of the logs = exp of the log of the product = the product.


What if the field contains the value of 0, than it doesn't works. 3*0 = 0, but it returns 1.

Alex, you are correct.

That particular formula cannot handle ANY non-positive number because the LOG() function is undefined for values less than or equal to zero. I just reviewed the archives and realized that this point has never been discussed before (I thought it had). Good catch.


That's way I reposted it, because the data I need to multiply has sometimes 0 in it. I already searched the
archives and googled for it, but no answer found. I would save a lot of headache if I could save this problem.


In the interest of giving credit where credit is due, here is Harald's original answer:
http://lists.mysql.com/mysql/166172



Yes, a lot of credit to him. It helped me alot, and with me more people I guess.



AC

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to