Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

SQL Query where conditions issue

Hi Experts,

I trying this below query

SELECT T0.[TransId], T1.[Account], T2.[AcctName], T1.[Debit], T1.[Credit], T1.[OcrCode3], T0.[TransType] FROM OJDT T0  INNER JOIN JDT1 T1 ON T0.TransId = T1.TransId INNER JOIN OACT T2 ON T1.Account = T2.AcctCode WHERE T2.[GroupMask] in (4,5) and T1.[OcrCode3] IS NOT NULL and T0.[RefDate] >=[%0] AND  T0.[RefDate] <=[%1]

GROUP BY T0.[TransId], T1.[Account], T2.[AcctName], T1.[Debit], T1.[Credit], T1.[OcrCode3], T0.[TransType]

Whereas though i have defined where condition for  T1.[OcrCode3] IS NOT NULL . Still it is listing me the null OcrCode3 lines.

What could be issue ?

Thanks in advance,

Regards,
Dwarak

Former Member
replied

use only T1.[OcrCode3]<>'' 

SELECT T0.[TransId], T1.[Account], T2.[AcctName], T1.[Debit], T1.[Credit], T1.[OcrCode3], T0.[TransType]

FROM OJDT T0  INNER JOIN JDT1 T1 ON T0.TransId = T1.TransId INNER JOIN OACT T2 ON T1.Account = T2.AcctCode

  WHERE T2.[GroupMask] in (4,5) and T1.[OcrCode3]<>''  and T0.[RefDate] >=[%0] AND  T0.[RefDate] <=[%1]

GROUP BY T0.[TransId], T1.[Account], T2.[AcctName], T1.[Debit], T1.[Credit], T1.[OcrCode3], T0.[TransType]

--Manish

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question