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. 

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

Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine


Alex croes <[EMAIL PROTECTED]> wrote on 12/21/2004 05:08:01 PM:

> 
> 
> Michael Stassen wrote:
> 
> > No, but Harold Fuchs gave the following solution to Shawn Green in an 
> > earlier thread on this topic <http://lists.mysql.com/mysql/166184>.
> >
> > 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
> 
> 
> 
> -- 
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]
> 

Reply via email to