select DATE_FORMAT(A.JDATE, "%m-%d-%Y"), A.JNO, A.DRACCTCODE, B.DRACCTNAME, A.CRACCTCODE, C.CRACCTNAME, A.AMOUNT, A.REFNO, A.REFDATE, A.NARRATION, 
sum(case when A.DRACCTCODE = 'I00001' then (A.AMOUNT) else 0 end) as TOTDR, 
sum(case when A.CRACCTCODE = 'I00001' then (A.AMOUNT) else 0 end) as TOTCR, COUNT(*) as TOTREC from Journal A
left join (Select ACCTCODE, ACCTNAME as DRACCTNAME from acctinf) B on A.DRACCTCODE = B.ACCTCODE
left join (Select ACCTCODE, ACCTNAME as CRACCTNAME from acctinf) C on A.CRACCTCODE = C.ACCTCODE
where (A.DRACCTCODE = 'I00001' or A.CRACCTCODE = 'I00001') and A.JDATE >= '2022-03-01' and A.JDATE <= '2022-03-31' group by A.JNO order by A.JDATE, A.JNO