### Geometric Annual Return in SQL

Here is some quick-and-dirty SQL to calculate an geometric annual return (as a percent) from a column of monthly returns (in percents).
/* Convert the annualized number back to a percent */ SELECT (T3.AnnHPR - 1) * 100 AS GeomAnnRet FROM ( /* Annualize the holding period return */ SELECT POWER(T2.HPR, 12.0 / T2.NumReturns) AS AnnHPR FROM ( /* Calculate the holding period return over the time period. POWER(10, SUM(LOG10(n))) is a simulated PRODUCT(n) aggregate function.