日期:2014-05-18 浏览次数:20373 次
select @a=sum(t1.c1), @b=sum(CASE WHEN t2.d= 1 THEN t2.e ELSE t2.e/100 *@a end), @a-@b from t1,t2 where t1.f=t2.f
------解决方案--------------------
declare @a as int select @a = sum(t1.c1) from t1 declare @b as int select @b = sum(CASE WHEN t2.d = 1 THEN t2.e ELSE t2.e/100 * @a) from t1 , t2 where t1.f=t2.f select @a - @b
------解决方案--------------------
declare @a decimal(10,2),@b decimal(10,2) select @a=sum(c1) from t1 select @b=sum(CASE WHEN t2.d= 1 THEN t2.e ELSE t2.e/100 * @a end) from t1,t2 where t1.f=t2.f select @a-@b
------解决方案--------------------
我在4楼的是返回一个值.
------解决方案--------------------
sum只返回1行阿,你没有group,返回什么列
------解决方案--------------------
关注,学习!
------解决方案--------------------
看不懂
------解决方案--------------------
..
------解决方案--------------------
..