当运行下面的查询时,t.status is NULL
它会给我不同的计数(我认为这是不正确的)。
如何获取计数NOT IN ('Cancelled', 'Duplicate')
但在计数中包含NULL
值行
对于以下查询,我得到的计数为423
select count(*) from QC10.DEFECTS d
inner join QC10.DEFECTS_TRAN t on D.RECORD_ID=T.DEFECT_ID_FK_DT
where
T.LATEST_RECORD='Y'
and
(t.status NOT IN ('Cancelled', 'Duplicate'))
但是当我运行以下查询时,我得到8530作为计数
select count(*) from QC10.DEFECTS d
inner join QC10.DEFECTS_TRAN t on D.RECORD_ID=T.DEFECT_ID_FK_DT
where
T.LATEST_RECORD='Y'
and
(t.status NOT IN ('Cancelled', 'Duplicate'))
or (t.status IS NULL)