0

I want to multiply column values within a table using an aggregate function in MYSQL similar to sum(column1) or avg(column1). I have tried product(column1) but the product function does not work. Kindly assist.

KMarto
  • 300
  • 2
  • 23
  • Please provide a few rows of sample data and the expected result. – The Impaler Jun 08 '22 at 13:09
  • Just by multiplying a few rows you can get really big numbers and will run into data type overflows pretty quickly. I don't know if it makes sense to multiply more than a few rows. Please elaborate. – The Impaler Jun 08 '22 at 13:12

1 Answers1

2

If all your values are integers greater than zero, you can do:

round(exp(sum(log(column1))))
ysth
  • 96,171
  • 6
  • 121
  • 214