1
Answer

Incorrect Syntax in case Statement

Photo of Ramco Ramco

Ramco Ramco

Mar 15
85
1

Hi

 In below code i and getting error Incorrect Syntax . I want if in any record -120 exists .

Case When (Select "staType" from INV4 where "DocEntry" = T0."DocEntry" and "StcCode" = t2."StcCode") In ('-120')  then sum(t2."BaseSum") else sum(t2."BaseSum")/2 End As "BaseSum",


----------------------------------------

select 
t0."BPLName",
t0."DocNum",t0."DocDate",Max(t0."CardCode") As "CardCode",Max(t0."CardName") As "CardName",t2."StcCode",
Case When (Select "staType" from INV4 where "DocEntry" = T0."DocEntry" and "StcCode" = t2."StcCode") In ('-120')  then sum(t2."BaseSum") else sum(t2."BaseSum")/2 End As "BaseSum",

Max(T0."DocTotal"+T0."DpmAmnt") As "Total Amount",
ROW_NUMBER() OVER (PARTITION BY t0."DocEntry" ORDER BY t0."DocNum") AS "RowNum"
from oinv t0 
left join inv4 t2 on t2."DocEntry" = t0."DocEntry"
where t0."DocDate" >= TO_DATE(:FromDate) AND  t0."DocDate" <= TO_DATE(:ToDate) 
group by t0."Series",t0."BPLName",t0."DocEntry",t0."DocNum",t0."DocDate",t2."StcCode",t0."CardCode",t0."ShipToCode"

Thanks

Answers (1)