/* Convert the annualized number back to a percent */SELECT(T3.AnnHPR-1)*100ASGeomAnnRetFROM(/* Annualize the holding period return */SELECTPOWER(T2.HPR,12.0/T2.NumReturns)ASAnnHPRFROM(/* Calculate the holding period return over the time
period.
POWER(10, SUM(LOG10(n))) is a simulated PRODUCT(n)
aggregate function.
The precision of POWER is determined by the precision
of the first argument, so use a lot of decimals. */SELECTPOWER(10.0000000000000000,SUM(LOG10(T.MonthReturn)))ASHPR,COUNT(*)ASNumReturnsFROM(/* Convert all percent returns to multipliers (1% ->
1.01) */SELECT1+MonthPctReturn/100ASMonthReturnFROM...)AST)AST2)AST3
Update 2008-01-30 10:52PM: Here’s the equivalent “one-liner”: