Using aggregate function in custom function
You would not use another aggregate function.  You would define your aggregate "from scratch".  I am surprised there is not an existing aggregate that does this, but I have not found one.