Hi
I have below query and want to display Balance.
Declare @frDate Date set @frDate = '2022/08/18' Declare @toDate Date set @toDate = '2022/08/18' Select T0.code, (select sum (Credit-Debit) from J1 where refdate <= @frDate and name = T0.Code) - (select Amount from Customer where code = T0.Code) 'Opening Balance', (Select sum(Amount) from order A0 where A0.code = T0.code and A0.date between @frDate and @toDate) 'Sales', (Select sum(value) from Pay A0 where A0.code = T0.code and A0.date between @frDate and @toDate) 'Payment' from order T0 inner join Customer t1 on T0.code = t1.Code where and T0.Date between @frDate and @toDate group by T0.Code
Thanks