declare @Fyear int,@Fperiod int
select @Fyear=fvalue from t_systemprofile where fkey='currentyear' and fcategory='gl'
select @Fperiod=fvalue from t_systemprofile where fkey='currentperiod' and fcategory='gl'
delete from t_balance where fyear*100+fperiod>@Fyear*100+@Fperiod
如果每项都有应收和应付就很容易:
SELECT t1.name,t1.money as 应收,t2.money as 应付
FROM Bill t1 inner join Bill t2 on t1.name=t2.name where t1.type='应收' and t2.type='应付'
没有我就不会了