# SQL SUM显示问题

0

---单个SQL
1.
SELECT  point FROM  dbo.ShopPoint WHERE     ShopPoint.createtime BETWEEN '2009-06-01 ' AND'2009-07-01 ' AND ShopPoint.sid = '240' AND ShopPoint.point > 0

SUM结果为 1097

2.
SELECT  point FROM  dbo.ShopPoint WHERE     ShopPoint.createtime BETWEEN '2009-07-01 ' AND'2009-08-01 '   AND ShopPoint.sid = '240' AND ShopPoint.point > 0

SUM结果为1253

3.

SELECT SUM(June.point) AS   JuneData ,SUM(July.point) AS   JulyData
FROM
( SELECT  point FROM  dbo.ShopPoint WHERE     ShopPoint.createtime BETWEEN '2009-06-01 ' AND'2009-07-01 '
AND ShopPoint.sid = '240' AND ShopPoint.point > 0)  AS June,
( SELECT  point FROM  dbo.ShopPoint WHERE     ShopPoint.createtime BETWEEN '2009-07-01 ' AND'2009-08-01 '
AND ShopPoint.sid = '240' AND ShopPoint.point > 0)  AS July

4.
SUM结果分别：3291，1253了为什么呢？

0

SELECT June.JuneData,July.JulyData

FROM
( SELECT  SUM(point) AS JuneData FROM  dbo.ShopPoint WHERE     ShopPoint.createtime BETWEEN '2009-06-01 ' AND'2009-07-01 '
AND ShopPoint.sid = '240' AND ShopPoint.point > 0)  AS June,
( SELECT  SUM(point) AS JulyData FROM  dbo.ShopPoint WHERE     ShopPoint.createtime BETWEEN '2009-07-01 ' AND'2009-08-01 '
AND ShopPoint.sid = '240' AND ShopPoint.point > 0)  AS July

您需要登录以后才能回答，未注册用户请先注册