结果不会出现空值

时间:2017-11-02 03:47:32

标签: sql oracle

我需要获得类型不等于'C'的类型。结果还需要包含null类型。这是我的查询。

SELECT
(SELECT d.clm_name FROM CORPINFO.TBLCLIENTMAIN d WHERE 
d.clm_code=a.strice_companycode) AS CurrentInsuraceCompany
FROM leaseinfo.TRN_ICE_INSURANCECOVERNOTEENTR a
WHERE a.strice_conno='HQLE152609770'
AND a.strice_instype!='C';

在我的表中,我有4个strice_instype值。 'C' 'E' 'N' 和Null

现在我需要获得不等于'C'的记录。

它得到结果E和N.但它不会显示包含null的行作为strice_instype。

1 个答案:

答案 0 :(得分:2)

选项1:

AND (a.strice_instype IS NULL OR a.strice_instype != 'C')

选项2:

AND NVL(a.strice_instype,'NotC') != 'C'