I need a product
an aggregate function that MySQL doesn't provide.
I would like it to be in MySQL's flavor of SQL (that is, not in C).
How do I do this? What I'm stuck on is creating an aggregate function -- the docs don't seem to mention how this is done.
Examples of desired usage of a product
function:
mysql> select product(col) as a from `table`;
+------+
| a |
+------+
| 144 |
+------+
1 row in set (0.00 sec)
mysql> select col, product(col) as a from `table` group by col;
+-----+------+
| col | a |
+-----+------+
| 6 | 36 |
| 4 | 4 |
+-----+------+
2 rows in set (0.01 sec)