大侠指教一下,我该怎样从试图中得到我想要的数据呢?
程序代码:
CREATE OR REPLACE VIEW BUS_GCZHF AS SELECT saasdm,cph,SUM(je) je,gid,dwmc FROM ( SELECT saasdm,(SELECT dmc FROM bus_dwjbxxb_bf WHERE saasdm = a.saasdm) dwmc,(SELECT gcph FROM bus_gcxxb_bf WHERE bfgid = a.jcph) cph,jcph gid,SUM(jje) je FROM bus_jyjlb a WHERE a.ztbz = '99' GROUP BY saasdm,jcph UNION SELECT saasdm,(SELECT dmc FROM bus_dwjbxxb_bf WHERE saasdm = a.saasdm) dwmc,(SELECT gcph FROM bus_gcxxb_bf WHERE bfgid = a.wcph) cph,wcph gid,SUM(wje) je FROM bus_wxbyjlb a WHERE a.ztbz = '99' GROUP BY saasdm,wcph UNION SELECT saasdm,(SELECT dmc FROM bus_dwjbxxb_bf WHERE saasdm = a.saasdm) dwmc,(SELECT gcph FROM bus_gcxxb_bf WHERE bfgid = a.gcph) cph,gcph gid,SUM(gjfje) je FROM bus_gfglb a WHERE a.ztbz = '99' GROUP BY saasdm,gcph UNION SELECT saasdm,(SELECT dmc FROM bus_dwjbxxb_bf WHERE saasdm = a.saasdm) dwmc,(SELECT gcph FROM bus_gcxxb_bf WHERE bfgid = a.wcph) cph,wcph gid,SUM(wfk) je FROM bus_wzjlb a WHERE a.ztbz = '99' GROUP BY saasdm,wcph UNION SELECT saasdm,(SELECT dmc FROM bus_dwjbxxb_bf WHERE saasdm = a.saasdm) dwmc,(SELECT gcph FROM bus_gcxxb_bf WHERE bfgid = a.scph) cph,scph gid,(CASE WHEN SUM(spcje-sbxje) > 0 THEN SUM(spcje-sbxje) ELSE 0 END) je FROM bus_sgjlb a WHERE a.ztbz = '99' GROUP BY saasdm,scph UNION SELECT saasdm,(SELECT dmc FROM bus_dwjbxxb_bf WHERE saasdm = a.saasdm) dwmc,(SELECT gcph FROM bus_gcxxb_bf WHERE bfgid = a.ncph) cph,ncph gid,SUM(nnjfy) je FROM bus_njjlb a WHERE a.ztbz = '99' GROUP BY saasdm,ncph UNION SELECT saasdm,(SELECT dmc FROM bus_dwjbxxb_bf WHERE saasdm = a.saasdm) dwmc,(SELECT gcph FROM bus_gcxxb_bf WHERE bfgid = a.bcph) cph,bcph gid,SUM(btbje) je FROM bus_bxjlb a WHERE a.ztbz = '99' GROUP BY saasdm,bcph) GROUP BY saasdm,dwmc,cph,gid;
这是项目中我写的一个视图,现在我想把每个 union 连接中的SUM取出来,显示在前台的列表中,该怎么取呢 ?