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
/*--Output--
12
*/
CREATE OR REPLACE AGGREGATE FUNCTION `your_project_id.your_dataset_id.geometric_mean`(`col` float64)
RETURNS float64 AS (EXP(SUM(LN(col))/COUNT(col)))
OPTIONS ( description = '''Finds the geometric mean of a column <value>.''')
SQL User Defined Aggregate Function (SQL UDAF)
See something wrong? Contact us or report an issue on Github.