【发布时间】:2017-04-26 20:40:10
【问题描述】:
我有一张桌子。 此表中有一些示例数据。
表格数据:
从表中选择 col1
结果集:
col1
1+2+3+45-6+7+8-9
1+2+3+45-6+7+89
1+2+3+45-6+7-8+9
1+2+3+45-6+7-8-9
...
..
.
有没有办法计算列数据?
像这样:
select col1,Calculate(col1) as col2 from table
col1 col2
----------------- -------------
1+2+3+45-6+7+8-9 51
1+2+3+45-6+7+89 141
1+2+3+45-6+7-8+9 53
1+2+3+45-6+7-8-9 35
【问题讨论】:
-
找到comprehensive answer here 并阅读那里给出的 Erland 答案的链接...
-
参见this answer 的类似问题,需要 CLR 函数。
-
感谢@Shnugo 这个帖子很有用---> stackoverflow.com/a/9850919/7820095
标签: tsql