| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 362 人关注过本帖
标题:大侠指教一下,我该怎样从试图中得到我想要的数据呢?
只看楼主 加入收藏
刘杰明
Rank: 8Rank: 8
来 自:山东大学威海校区
等 级:蝙蝠侠
帖 子:155
专家分:872
注 册:2011-6-20
结帖率:63.64%
收藏
 问题点数:0 回复次数:1 
大侠指教一下,我该怎样从试图中得到我想要的数据呢?
程序代码:
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取出来,显示在前台的列表中,该怎么取呢 ?
搜索更多相关主题的帖子: 数据 
2012-05-14 16:49
刘杰明
Rank: 8Rank: 8
来 自:山东大学威海校区
等 级:蝙蝠侠
帖 子:155
专家分:872
注 册:2011-6-20
收藏
得分:0 
解决了!

______________________________加油__!__!___!
2012-05-16 16:24
快速回复:大侠指教一下,我该怎样从试图中得到我想要的数据呢?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.028380 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved