简单实现一下 比如:
[销售表] [销售编号] [销售人员] [销售额] [销售数量] [销售时间]
1 XXX 200 1 2009-03-31 08:14:23 2 XXX 352 2 2009-03-31 08:24:33 3 XXX 400 3 2009-03-31 08:29:36 4 XXX 200 1 2009-03-31 09:10:07 5 XXX 100 1 2009-03-31 09:30:12 6 XXX 300 1 2009-03-31 10:04:53
SQL语句:
Code
1select substr(销售时间,12,2) as 销售时段,sum(销售额) as 销售总额,count(销售数量) as 销售总数2from 销售表3where 销售时间 like '2009-03-31%'4group by (substr(销售时间,12,2))
查询结果:
[销售时段] [销售总额] [销售总数]
08 952 6 09 300 2 10 300 1
转载于:https://www.cnblogs.com/Kurodo/archive/2009/03/31/1426242.html
相关资源:使用sql语句查询的数据按时间递增累加