22,207
社区成员
发帖
与我相关
我的任务
分享
declare @r int,@e int
set @r=1 --要计算的部件的序号
select @e=min(序号) from tb
where 序号>@r and len(阶层)<=(select 阶层 from tb where 序号=@r)
if @r is null select @r=max(序号) from tb
select sum(成本) 部件成本 from tb
where 序号>@r and 序号<=@e