geometric_mean(col)
Finds the geometric mean of a column <value>.
CREATE OR REPLACE AGGREGATE FUNCTION `justfunctions.eu.geometric_mean`(`col` float64)
RETURNS float64 AS (EXP(SUM(LN(col))/COUNT(col)))
OPTIONS ( description = '''Finds the geometric mean of a column <value>.''')
Example
WITH sample AS (
SELECT 4 AS col_1
UNION ALL
SELECT 5
UNION ALL
SELECT 5
)
SELECT `justfunctions.eu.geometric_mean`(col_1)
FROM sample
12