create or replace view vw_zy_zzddydzfpxx as select a.JKDID0 as JKDH00, (select sum(nvl(tt.HJJE00,0)-nvl(tt.YBYL05,0)) from ZY_PJSYQK t ,ZY_JZB000 tt where t.JKDID0 > 0 and t.PLBH00 = 3 and t.WBPJXH is not null and t.pjh000=tt.pjh000 and t.JKDID0=a.JKDID0) as DZFPJE, --电子发票总金额 nvl(count(1),0) as DZFPSL, --开具电子发票数 nvl(sum(decode(a.WBPJLY,'03',1,'05',1,0)),0) as ZZFPSL, --换开纸质发票数 min(WBPJXH)PJQSH0, max(WBPJXH)PJZZH0, (select count(1)from vw_zy_zffpxh where JKDH00 =a.JKDID0)ZFFPSL from ZY_PJSYQK a where a.JKDID0 > 0 and a.PLBH00 = 3 and a.WBPJXH is not null and ((a.WBPJLY='05' and substrb(a.PJXH00,1,1) <> '-') or (a.WBPJLY in ('02','03','04'))) group by a.JKDID0;