on ‎2021 May 14 5:50 PM
Is there a general code for DSO report in query manager?
I have a setup of the code below, however it brings errors and I'm unable to fix it properly.
Could anyone tell me what are the issues here?
Select TT.CardCode as "Customer Code", TT.CardName as "Customer", (Select MainCurncy from OADM) AS "Currency",TT.Balance as "Balance",
Case When
SF.Balance/[SF].[DSO1] <=0 THEN 0
ELSE SF.Balance/[SF].[DSO1] END "DSO",
Case
When TT.GroupNum=-1 THEN 0
When TT.GroupNum=2 THEN 10
When TT.GroupNum=15 THEN 15
When TT.GroupNum=3 THEN 14
When TT.GroupNum=4 THEN 20
When TT.GroupNum=5 THEN 30
When TT.GroupNum=6 THEN 40
When TT.GroupNum=17 THEN 42
When TT.GroupNum=16 THEN 45
When TT.GroupNum=7 THEN 50
When TT.GroupNum=8 THEN 60
When TT.GroupNum=9 THEN 70
When TT.GroupNum=10 THEN 80
When TT.GroupNum=11 THEN 90
When TT.GroupNum=12 THEN 100
When TT.GroupNum=13 THEN 110
When TT.GroupNum=14 THEN 120
END
"Payment Terms"
FROM OCRD TT
Right Join(
Select T0.CardCode,T0.Balance "Balance",
Case
WHEN [SM].[MinDate] < DATEADD(Month,-3, getDate()) THEN [SM].[Total]/91
ELSE [SM].[Total]/DateDiff(day, [SM].[MinDate] ,getDate())
END
"DSO1" from OCRD T0
Right Join
(
Select T1.CardCode "CardCode",[SD].[MinDate], SUM(T1.DocTotal) "Total" from OINV T1
left Join
(
Select CardCode, Min(DocDate) AS "MinDate" from OINV Group By CardCode
) SD ON T1.CardCode= [SD].[CardCode]
where T1.DocDate > DATEADD(Month,-3, getDate())
Group BY T1.CardCode,[SD].[MinDate]
) SM ON T0.CardCode=[SM].[CardCode]) SF on TT.CardCode=[SF].[CardCode]
Order BY TT.CardCode
Request clarification before answering.
| User | Count |
|---|---|
| 7 | |
| 6 | |
| 4 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.