---电子凭证使用人次统计:
select xm as 姓名,sum(jzrc) as 总结算人次,sum(sfrc) as 电子凭证人次 from(
/收费结算人次/
select b.xm , count(distinct(a.sfsb)) jzrc,0 sfrc
from mz_mzsfk1 a, gy_zgxx b where --qudaodm=5
sfrq between to_date('2021/09/30','yyyy/mm/dd') and to_date ('2021-09-30 23:59:59','yyyy-mm-dd hh24:mi:ss')
and a.czgh=b.zgid
and brlb=-3
group by a.czgh, b.xm
union all
/电子凭证人次/
select b.xm, 0 jzrc ,sum(decode(nvl(a.zfgh,'none'),'none',1,-1)) sfrc
from mz_mzsfk1 a, gy_zgxx b where qudaodm=5
and sfrq between to_date('2021/09/30','yyyy/mm/dd') and to_date ('2021-09-30 23:59:59','yyyy-mm-dd hh24:mi:ss')
and a.czgh=b.zgid
group by a.czgh, b.xm )
group by xm
不知道是不是再给个意思 我改的我写备注了 希望对你有帮助
select xm as 姓名,sum(jzrc) as 总结算人次,sum(sfrc) as 电子凭证人次
from(
/收费结算人次/
select b.xm , count(distinct(a.sfsb)) jzrc,0 sfrc
from mz_mzsfk1 a, gy_zgxx b where --qudaodm=5
sfrq between to_date('2021/09/30','yyyy/mm/dd') and to_date ('2021-09-30 23:59:59','yyyy-mm-dd hh24:mi:ss')
and a.czgh=b.zgid
and brlb=-3
and a.brxm not in (select brxm from zj_jzxx where nl<14)//这里是我加的
group by a.czgh, b.xm
union all
/电子凭证人次/
select b.xm, 0 jzrc ,sum(decode(nvl(a.zfgh,'none'),'none',1,-1)) sfrc
from mz_mzsfk1 a, gy_zgxx b where qudaodm=5
and sfrq between to_date('2021/09/30','yyyy/mm/dd') and to_date ('2021-09-30 23:59:59','yyyy-mm-dd hh24:mi:ss')
and a.czgh=b.zgid
and a.brxm not in (select brxm from zj_jzxx where nl<14)//这里是我加的
group by a.czgh, b.xm
)
group by xm