日期:2014-05-16 浏览次数:20855 次
select cusName,sum(Money),sum(WaterNum) from 表 group by cusName union all select '总计',sum(Money),sum(WaterNum) from 表
------解决方案--------------------
日
select selltime,sum(money)
from 表名
group by selltime
月
select selltime,sum(money)
from 表名
where selltime between 2009-06-1 and 2009-06-31
group by selltime
年
select selltime,sum(money)
from 表名
where selltime between 2009-01-1 and 2009-12-31
group by selltime
www.hzyatong.cn
www.tuoye.net
------解决方案--------------------
1、按年统计:
年份 Money WaterNum
2009 ... ...
2010 560 56
2011 ... ...
select year(SellTime) ,cusName,sum(Money),sum(WaterNum) from 表 group by year(SellTime),cusName
------解决方案--------------------
年
select year(selltime),sum(Money),sum(WaterNum) from tt group by year(selltime)
月
select month(selltime),sum(Money),sum(WaterNum) from tt group by month(selltime)