-余额比上一季度末增量
set @lastqtr=dbo.f_getlastqtr(@trans_date)
set @inc_qtr=
(select sum(case when flag='0'then -amt else amt end)
from t_journal
where account_no=@account_no and month(trans_date)<=month(@trans_date)and month(trans_date)>month(@lastqtr) )
set @lastqtr=dbo.f_getlastqtr(@trans_date)
set @inc_qtr=
(select sum(case when flag='0'then -amt else amt end)
from t_journal
where account_no=@account_no and month(trans_date)<=month(@trans_date)and month(trans_date)>month(@lastqtr) )
而另一个与第一个程序相同,显示结果就是对的