Hi experts,
A customer has a request which i have tried but it does not look like the query is meeting the required results.
The customer wants a query that will show it's offset account as well as accounts which are basically cash relevant account(Bank accounts).
The customer also wants to see the category to which the offset account is assigned to. Transaction with both accounts and offset account been cash relevant should not show in the query.
Below is what i have done but the output is not right. I will need someone to check what i am not doing right to solve this issue. It is quite urgent;
SELECT JDT1.ContraAct as 'OffSet_Account',JDT1.Account as 'Account',JDT1.Debit,JDT1.Credit,OACG.Name AS 'Category',JDT1.TransId
FROM JDT1
INNER JOIN OACT ON OACT.AcctCode =JDT1.ContraAct
left JOIN OACG ON OACG.AbsId = OACT.Category
WHERE OACT.Finanse ='Y' and JDT1.Account LIKE '500%%'
AND JDT1.ContraAct NOT LIKE '500%%'
UNION ALL
SELECT JDT1.ContraAct as 'OffSet_Account',JDT1.Account as 'Account', Debit,Credit ,(case when ContraAct like 'S%%' THEN 'Trade and other Payables'
when ContraAct like 'C%%' THEN 'Trade and Other Receivables'
else OACG.Name end)'Category',JDT1.TransId
FROM OACT INNER JOIN JDT1 ON JDT1.Account =OACT.AcctCode
left JOIN OACG ON OACG.AbsId = OACT.Category
WHERE OACT.Finanse = 'Y' and JDT1.Account LIKE '500%%' AND JDT1.ContraAct NOT LIKE '500%%'
Regards
Justice