跪求一条SQL语句的问题!急!在线等!高手们,帮个忙!

select areaLandBuilding,areaSumUp from Projectinfo(
where startDatePlan='2008-8-25'
and endDatePlan='2008-8-25'
and startDateFact='2008-8-25'
and XM_XMZhuangTai='05020002'
就这个SQL语句
(areaLandBuilding
areaSumUp)里存的是面积的数据。
求出它们各自的总和。
SQL语句怎么改?
条件是在那三个日期之间的。
怎么写?
我只知道betten..and...只能写两个
二我这有三个怎么写?

select SUM(areaLandBuilding) areaLandBuilding_SUM,
SUM(areaSumUp) areaSumUp_SUM
from Projectinfo(
where startDatePlan='2008-8-25'
and endDatePlan='2008-8-25'
and startDateFact='2008-8-25'
and XM_XMZhuangTai='05020002' ,

就是SQL中的聚合函数sum

给你引点我的SQL语言参考:
SUM
返回表达式中所有值的和,或只返回 DISTINCT 值。SUM 只能用于数字列。空值将被忽略。

语法
SUM ( [ ALL | DISTINCT ] expression )

参数
ALL

对所有的值进行聚合函数运算。ALL 是默认设置。

DISTINCT

指定 SUM 返回唯一值的和。

expression

是常量、列或函数,或者是算术、按位与字符串等运算符的任意组合。expression 是精确数字或近似数字数据类型分类(bit 数据类型除外)的表达式。不允许使用聚合函数和子查询。

返回类型
以最精确的 expression 数据类型返回所有表达式值的和。

表达式结果 返回类型
整数分类 int
decimal 分类 (p, s) decimal(38, s)
money 和 smallmoney 分类 money
float 和 real 分类 float

重要 当使用 CUBE 或 ROLLUP 时,不支持区分聚合,例如 AVG(DISTINCT column_name)、COUNT(DISTINCT column_name)、MAX(DISTINCT column_name)、MIN(DISTINCT column_name) 和 SUM(DISTINCT column_name)。如果使用了,Microsoft® SQL Server™ 将返回错误信息并取消查询。

示例
A. 在聚合和行聚合中使用 SUM
下列示例显示聚合函数和行聚合函数之间的区别。第一个示例显示只提供汇总数据的聚合函数,第二个示例显示提供详尽数据和汇总数据的行聚合函数。

USE pubs
GO
-- Aggregate functions
SELECT type, SUM(price), SUM(advance)
FROM titles
WHERE type LIKE '%cook'
GROUP BY type
ORDER BY type
GO

下面是结果集:

type
------------ -------------------------- --------------------------
mod_cook 22.98 15,000.00
trad_cook 47.89 19,000.00

(2 row(s) affected)

USE pubs
GO
-- Row aggregates
SELECT type, price, advance
FROM titles
WHERE type LIKE '%cook'
ORDER BY type
COMPUTE SUM(price), SUM(advance) BY type

下面是结果集:

type price advance
------------ -------------------------- --------------------------
mod_cook 19.99 0.00
mod_cook 2.99 15,000.00

sum
==========================
22.98
sum
==========================
15,000.00

type price advance
------------ -------------------------- --------------------------
trad_cook 20.95 7,000.00
trad_cook 11.95 4,000.00
trad_cook 14.99 8,000.00

sum
==========================
47.89
sum
==========================
19,000.00

(7 row(s) affected)

B. 计算多列的组合计
下例计算每类书籍的价格和预付款总和。

USE pubs
GO
SELECT type, SUM(price), SUM(advance)
FROM titles
GROUP BY type
ORDER BY type
GO

下面是结果集:

type
------------ -------------------------- --------------------------
business 54.92 25,125.00
mod_cook 22.98 15,000.00
popular_comp 42.95 15,000.00
psychology 67.52 21,275.00
trad_cook 47.89 19,000.00
UNDECIDED (null) (null)

(6 row(s) affected)

--
这份SQL语言参考如果需要的话,me我啊
^_^,
疑义相与析,SQL共欣赏

参考资料:LXH整理的SQL语言参考

温馨提示:答案为网友推荐,仅供参考
第1个回答  2008-09-27
改为即可
select
sum(areaLandBuilding),sum(areaSumUp) from ...本回答被提问者采纳
第2个回答  2008-09-27
要求和用sum()
你说的那个日期我没看懂!三个日期都一样嘛!怎么比较。
第3个回答  2008-09-27
select sum(areaLandBuilding),sun(areaSumUp) from Projectinfo
where startDatePlan='2008-8-25'
and endDatePlan='2008-8-25'
and startDateFact='2008-8-25'
and XM_XMZhuangTai='05020002'
相似回答