mas1963 said:
>>Following is full query and in POPDJB column it just displaying CapEX
That tells me that POPDJB is not truly NULL, and instead it has either a zero-length string or all spaces.
Try:
SELECT G.GLDGL AS Account, P.POPOID AS PONumber, G.GLDEDT AS EntryDate, A.APTRN1 AS InvoiceTrans, A.APTEDT AS EntryDate,
A.APTEDS AS Description, A.APTSU1 AS InvoiceStatus, A.APTBA6 AS APAmount, A.APTCKN AS Cheque#, A.APTDT4 AS ChequeDate,
A.APTDT5 AS ClearDate, G.GLDBA AS Amount, A.APTCKN AS CheckNum, A.APTDT4 AS CheckDate, A.APTDT5 AS ClearDate, G.GLDJB AS Job,
G.GLDGL AS Costcode, G.GLDBT AS JVN, PD.POPDEP AS Amount, PD.POPDJB as Type,
POPDJB = (CASE WHEN RTRIM(COALESCE(PD.POPDJB, '')) = '' THEN 'OpEX' ELSE 'CapEX' END)
FROM dbo.bpl_GLPD AS G LEFT OUTER JOIN
dbo.bpl_POPPD AS PD ON G.GLDPJ = PD.POPDPJ LEFT OUTER JOIN
dbo.bpl_APPT AS A ON G.GLDEN1 = A.APTEC1 AND G.GLDRN1 = A.APTRN1 AND G.GLDBT = A.APTBT AND G.GLDBE = A.APTBE LEFT OUTER JOIN
dbo.bpl_POPPO AS P ON G.GLDTM = P.POPOTM
WHERE (G.GLDBK = 'ACT') AND (G.GLDJB = 'BT09ADMIG') AND (G.GLDEDT >= '1080101') AND (G.GLDEDT <= '1091231')
ORDER BY G.GLDCC, G.GLDJB, G.GLDEDT, G.GLDJC, G.GLDBT, G.GLDBE, G.GLDBL
That will check for NULL, all spaces, or zero length string.