编辑:由于 OP 特别提到它0
不是空值,我们将查询更改为使用case
.
count(case when ivr.dw_dealer_id = 0 then 1 else ivr.dw_dealer_id end)
或者只使用带有 last 的查询OR
。
SELECT
ivr.dw_dealer_id,
ivr.dw_product_id,
ivr.dw_program_type_id,
ivr.dw_month_id,
TO_CHAR(ivr_update_dt, 'YYYYMM') buss_month,
count(ivr.dw_dealer_id) as counts
FROM idm_ivr_interaction ivr, stgdba.interactions intr
WHERE ivr.cti_rec_id = intr.pega_id
AND (intr.pega_id IS NULL OR ivr.cti_rec_id IS NULL)
环绕nvl
身份证...
SELECT
ivr.dw_dealer_id,
ivr.dw_product_id,
ivr.dw_program_type_id,
ivr.dw_month_id,
TO_CHAR(ivr_update_dt, 'YYYYMM') buss_month,
count(nvl(ivr.dw_dealer_id,1))
FROM idm_ivr_interaction ivr, stgdba.interactions intr
WHERE ivr.cti_rec_id = intr.pega_id
AND (intr.pega_id IS NULL OR ivr.cti_rec_id IS NULL)
- 顺便说一句,你正在使用的应该有一个
Group By
......count