Redian新闻
>
Townhouse 问题 (转载)
avatar
Townhouse 问题 (转载)# Living
l*9
1
【 以下文字转载自 Quant 讨论区 】
发信人: light009 (light009), 信区: Quant
标 题: SQL multiply all values of a column in table
发信站: BBS 未名空间站 (Wed Jun 25 17:35:13 2014, 美东)
I need to multiply all float values of a column in table if the column value
is positive. If I find a value is null or negative or not numeric, I raise
an error in SQL server 2008 R2.
given table t0:
col
1.5
2
given table t1:
col
2
-1
5
0
null
NaN
For t0 I should get 3, for t1, I should raise an error.
Any help would be appreciated.
avatar
l*n
2
今天收到卡了,给大家报个绿。 3类绿
感觉邮寄很快,7号从KY寄出,9号早上9点到San Jose分拣中心,然后12点就deliver到
家了
版花请帮我报个绿吧,我的timeline是:
PD:06/23/14
RD:05/23/17
Card:05/02/18
avatar
k*o
3
【 以下文字转载自 Investment 讨论区 】
发信人: kevicao (kevicao), 信区: Investment
标 题: Townhouse 问题
发信站: BBS 未名空间站 (Fri Jun 7 17:38:53 2013, 美东)
邻居说这个building 房顶leak, 他们修了几次还没好。 还说seal也不好,冬天冷。
这些问题大吗?
avatar
l*8
4
For MySQL:
SELECT EXP( SUM( LOG( IF(col >= 0, col, NULL) ) ) )
FROM your_table

value
raise

【在 l******9 的大作中提到】
: 【 以下文字转载自 Quant 讨论区 】
: 发信人: light009 (light009), 信区: Quant
: 标 题: SQL multiply all values of a column in table
: 发信站: BBS 未名空间站 (Wed Jun 25 17:35:13 2014, 美东)
: I need to multiply all float values of a column in table if the column value
: is positive. If I find a value is null or negative or not numeric, I raise
: an error in SQL server 2008 R2.
: given table t0:
: col
: 1.5

avatar
k*o
5
Re
avatar
l*9
6
Thanks !
for EXP( SUM( LOG )) , the floating point calculation of log(), and exp()
may not be efficient.
In my cases, the values are positive in most time.
Only in very few cases, I have negative, null values.
Are there more efficient method ?
thanks

【在 l*********8 的大作中提到】
: For MySQL:
: SELECT EXP( SUM( LOG( IF(col >= 0, col, NULL) ) ) )
: FROM your_table
:
: value
: raise

avatar
D*9
7
建议不要买了
avatar
l*8
8
Then you need to Create User-defined Aggregates
http://msdn.microsoft.com/en-us/library/ms190678.aspx

【在 l******9 的大作中提到】
: Thanks !
: for EXP( SUM( LOG )) , the floating point calculation of log(), and exp()
: may not be efficient.
: In my cases, the values are positive in most time.
: Only in very few cases, I have negative, null values.
: Are there more efficient method ?
: thanks

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。