我有4列如下
Name Alphabet Formula Value
Total1 A 20
Total2 B 10
Total3 C A+B
Total4 D C+A+B
-
我有A和B的值,通过存储过程如何计算我已知的total3和total 4值。
答案 0 :(得分:0)
尝试在存储过程中使用SUM。
在查询中添加SUM(A + B)AS ABName,SUM(ABName + A + B)AS ABCName
看看是否有帮助
答案 1 :(得分:0)
DECLARE @ValueA as int
DECLARE @Valueb as int
select @ValueA=sum(value) from yourTable where alphabet='A'
select @ValueB=sum(value) from yourTable where alphabet='B'
update yourTable set value=@ValueA + @ValueB where alphabet='C'