select * ,b-isnull((select sum(b) from b where where ID>a.ID),0) from b a
select sum(b)*1.0/100 from b
--> 测试数据
declare @tb table ([id] int,[b] nvarchar(20)) Insert into @tb select 001,'10222.22' union all select 002,'9850.33'
Select *,convert(decimal(18,2),[b]) as col from @tb /*(2 row(s) affected) id b col ----------- -------------------- --------------------------------------- 1 10222.22 10222.22 2 9850.33 9850.33(2 row(s) affected)*/
没看懂.
from b a
declare @tb table ([id] int,[b] nvarchar(20))
Insert into @tb
select 001,'10222.22' union all
select 002,'9850.33'
Select *,convert(decimal(18,2),[b]) as col from @tb
/*(2 row(s) affected)
id b col
----------- -------------------- ---------------------------------------
1 10222.22 10222.22
2 9850.33 9850.33(2 row(s) affected)*/