cancel
Showing results for 
Search instead for 
Did you mean: 

SQL Query where conditions issue

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

former_member184146
Active Contributor
0 Kudos

Hi,

Try this

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 or 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

Former Member
0 Kudos

Hi Manish,

Still the same.  whereas if i give "IS NULL" then it shows me only the null field values. But "IS NOT NULL" is not working  what could be the reason ?

Thanks with regards,

Dwarak

former_member184146
Active Contributor
0 Kudos

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

Answers (0)