declare @编号 varchar(10),@余额日期 datetime,@查询日期 datetime,@查询结果 numeric(18,2)
select @余额日期=日期,@查询结果=结余(元) from 个人结余 where 个人编号=@编号
select @查询结果=@查询结果+(case 状态 when '收' then (-1)*收支(元) when '支' then 收支(元) else 0 end) from where 个人编号=@编号 and 日期 between @余额日期 and @查询日期
print @查询结果
-------直接写的 未测
本文如未解决您的问题请添加抖音号:51dongshi(抖音搜索懂视),直接咨询即可。