读书人

!超简单的一个统计如何实现?分就这么

发布时间: 2012-02-16 21:30:36 作者: rapoo

求救!!!超简单的一个统计怎么实现???分就这么多啦。
求救!!!超简单的一个统计怎么实现???分就这么多啦。
表:销售号 时间 金额 员工 数量
SellNo SellTime Money cusName WaterNum
SH090606-000012009-6-16 17:06:28 100 张三 10
SH090606-000022009-6-16 17:39:09 50 李四 5
SH090608-000032009-6-18 13:17:00 100 三五 10
SH090617-000042009-6-17 11:55:45 50 李四 5
SH090918-000052009-9-18 20:27:10 100 小刘 10
SH091213-000062009-12-13 17:17:35 50 张三 5
SH091213-000072009-12-13 17:22:10 50 李四 5
SH091213-000082009-12-13 17:24:43 100 张三 10
SH100102-000092010-11-12 18:00:32 60 三五 6

1、按cusName统计:
cusName Money WaterNum
张三 250 25
李四 150 15
三五 160 16
总计 560 56

另外:如果想按年,月,日来统计应该怎么做?



[解决办法]
1、按cusName统计:
cusName Money WaterNum
张三 250 25
李四 150 15
三五 160 16
总计 560 56

SQL code
select cusName,sum(Money),sum(WaterNum)from 表group by cusNameunion allselect '总计',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 ... ...



SQL code
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)

读书人网 >Access

热点推荐