标题:这个一条查询语句该怎么写?
取消只看楼主
等待冰柠檬
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



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-314896-1-1.html




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

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