枢轴函数产生空值,我需要零

Pivot function producing nulls and I need zeros

我正在寻找一种更有效的方式来编写这段代码。问题是主元 table 产生空值,而我需要零,这样我就可以将这些列加在一起形成总计列。谢谢!

    select coll_group, sub_group, collector, 
    M0,
    M1,
    M2,
    M3,
    M4,
    M5
    M6,
    M7,
    M8,
    M9,
    M10,
    M11,
    M12,
    (M1+M2+M3+M4+M5+M6+M7+M8+M9+M10+M11+M12) Total
    from(
    select coll_group, sub_group, collector,
        case when "0_M" is null then 0 else "0_M" end M0 , 
        case when "1_M" is null then 0 else "1_M" end M1 , 
        case when "2_M" is null then 0 else "2_M" end M2 , 
        case when "3_M" is null then 0 else "3_M" end M3 , 
        case when "4_M" is null then 0 else "4_M" end M4 ,
        case when "5_M" is null then 0 else "5_M" end M5 , 
        case when "6_M" is null then 0 else "6_M" end M6 , 
        case when "7_M" is null then 0 else "7_M" end M7 ,
        case when "8_M" is null then 0 else "8_M" end M8 , 
        case when "9_M" is null then 0 else "9_M" end M9 , 
        case when "10_M" is null then 0 else "10_M" end M10 , 
        case when "11_M" is null then 0 else "11_M" end M11 , 
        case when "12_M" is null then 0 else "12_M" end M12                
        from
    (select * from (
      select coll_group, sub_group, collector, low_activity_days,
        months_between(trunc(sysdate, 'MM'), month) as month_offset
      from low_activity_days_collect_t
      where month >= add_months(trunc(sysdate, 'MM'), -13)
      and month < trunc(sysdate, 'MM')
    ) src
    pivot (sum(low_activity_days) as M
      for month_offset in (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12))))

使用NVL(0_M,0) M0代替case when "0_M" is null then 0 else "0_M" end M0等等...

据我所知,null和1的和是1,何必担心呢?