Ramco Ramco

Ramco Ramco

  • 431
  • 3.5k
  • 565.9k

Case When STatement

Jan 25 2025 6:49 AM

Hi

 I have below code . I want if A1.Invtype = 18 then alias A0 should be PCH1 , if A1.Invtype = 19 then alias A0 should be RPC1

 

SELECT T1."TransType", T1."Account",Sum(T1."Debit") As "Debit", Sum(T1."Credit") As "Credit",

CASE 
WHEN T1."TransType" = '46' THEN 
(Select max(A0."LocCode") from PCH1 A0 inner join VPM2 A1 on A0."DocEntry" = A1."DocEntry"
inner join OVPM A2 on A2."DocEntry" = T1."CreatedBy")

Else '0'
END AS "Location"

FROM OJDT T0  INNER JOIN JDT1 T1 ON T0."TransId" = T1."TransId" 

Thanks


Answers (4)