乘积聚合函数


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

MSSQL中没有直接的如SUM一样的乘积函数,不过可通过变换得到。
由log(a) + log(b) + loa(c) = log(a*b*c) 得到:
a*b*c = exp(log(a) + log(b) + loa(c)) (exp:e的指数, 如EXP(10) = e^10 ),
因log(a) + log(b) + loa(c)可以通过加法得到,故乘积也可得到。

如下:
select EXP(sum(LOG(quantity))) from(
select 1 quantity
union select 2
union select 3
union select 4
union select 5
)m