# Mysql – How to create a user-defined aggregate function? (Part 2)

aggregateMySQL

I'm refering to this question:

How do I create a user-defined aggregate function?

My table contains Zero-Values so I have tried the example of ypercubeᵀᴹ but I got the message that

(NOT EXISTS (SELECT 1 FROM testmult WHERE wert = 0))


is a boolean and it can't be muliplied with

EXP(SUM(LOG(wert)))


(Error: "boolean * double precision")

So how can I solve it?

Use MIN() instead of trying to invent PROD(). That way, any 0 will lead to a zero result (assuming all the values are non-negative).