locked
Incorrect Syntax near ) RRS feed

  • Question

  • User-797751191 posted

    Hi

      On below code i get above error

    select T0.DocEntry,T0.DocDate,T0.CardCode
    ,T1.ItemCode,
    ,Coalesce((Case When T4.Street = '' Then Null Else T4.Street + ' ' End) + ',' + CHAR(10) + ',' +		
    (Case When T4.Block  = '' Then Null Else T4.Block + ' ' End) + ',' + CHAR(10) + ',' +
    (Case When T4.ZipCode  = '' Then Null Else T4.ZipCode + ' ' End) + ',' + CHAR(10) + ',' +
    (Case When T4.City  = '' Then Null Else T4.City + ' ' End) + ',' + CHAR(10) + ',' +
    (Case When T4.Country  = '' Then Null Else T4.Country + ' ' End) + ',' + CHAR(10) + ',' +
    (Case When T4.State  = '' Then Null Else T4.State End)) 
    ,T5.Chapter,T5.ChapterId
    ,T6.Location
    ,T7.AcctName
    FROM OPOR T0
    inner join POR1 T1 on T0.DocEntry = T1.DocEntry
    inner join OCRD T2 on T2.CardCode = T0.CardCode
    inner join OITM T3 on T1.ItemCode = T3.ItemCode
    LEFT OUTER JOIN CRD1 T4 ON T4.CardCode= T0.CardCode

    Thanks

    Tuesday, December 31, 2019 5:54 AM

Answers

  • User288213138 posted

    Hi jsshivalik,

    ,T1.ItemCode,
    ,

    An extra comma after ItemCode.

    (Case When T4.State  = '' Then Null Else T4.State End)) 

    Coalesce() Function must have at least 2 parameters.

    You can try below code:

    select T0.DocEntry,T0.DocDate,T0.CardCode
    ,T1.ItemCode,
    Coalesce((Case When T4.Street = '' Then Null Else T4.Street + ' ' End) + ',' + CHAR(10) + ',' +		
    (Case When T4.Block  = '' Then Null Else T4.Block + ' ' End) + ',' + CHAR(10) + ',' +
    (Case When T4.ZipCode  = '' Then Null Else T4.ZipCode + ' ' End) + ',' + CHAR(10) + ',' +
    (Case When T4.City  = '' Then Null Else T4.City + ' ' End) + ',' + CHAR(10) + ',' +
    (Case When T4.Country  = '' Then Null Else T4.Country + ' ' End) + ',' + CHAR(10) + ',' +
    (Case When T4.State  = '' Then Null Else T4.State End),' ') 
    ,T5.Chapter,T5.ChapterId
    ,T6.Location
    ,T7.AcctName
    FROM OPOR T0
    inner join POR1 T1 on T0.DocEntry = T1.DocEntry
    inner join OCRD T2 on T2.CardCode = T0.CardCode
    inner join OITM T3 on T1.ItemCode = T3.ItemCode
    LEFT OUTER JOIN CRD1 T4 ON T4.CardCode= T0.CardCode

    Best regards,

    Sam

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, December 31, 2019 7:25 AM