| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 838 人关注过本帖
标题:这个一条查询语句该怎么写?
取消只看楼主 加入收藏
等待冰柠檬
Rank: 2
来 自:浙江温州
等 级:论坛游民
帖 子:208
专家分:70
注 册:2008-6-25
结帖率:66.67%
收藏
已结贴  问题点数:10 回复次数:1 
这个一条查询语句该怎么写?
Select VehicleBrands,sum(Amount)
          from CostReports
          where CostReports.CostType = 1 and CreateTime between StartDate and EndDate
          group by VehicleBrands

      Select VehicleBrands,sum(Amount/ApportionMonth)
          from CostReports
          where CostReports.CostType = 2  and ThisMonth < StartMonth + ApportionMonth
      and ApportionMonth > 0
          group by VehicleBrands
select VehicleBrands,sum(Amount)
          from CostReports
          where CostReports.CostType = 3
          group by VehicleBrands
如何将这三条语句查询的的结果进行累加
Select VehicleBrands,sum(第1种查询的结果+第2种查询的结果+第3种查询的结果) as ReportCost
from CostReports
group by VehicleBrands
注意:第X种查询的结果用查询语句表示


[ 本帖最后由 等待冰柠檬 于 2010-8-5 15:19 编辑 ]
搜索更多相关主题的帖子: 语句 查询 
2010-08-05 15:05
等待冰柠檬
Rank: 2
来 自:浙江温州
等 级:论坛游民
帖 子:208
专家分:70
注 册:2008-6-25
收藏
得分:0 
好像有问题吧!版主!
2010-08-06 10:11
快速回复:这个一条查询语句该怎么写?
数据加载中...
 
   



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

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