求一时间段SQL语句
表A
ID ADD_TIME SL
1 2011-09-22 11:23:52 2
2 2011-09-24 11:36:52 4
3 2011-09-24 14:21:52 2
4 2011-09-24 15:25:52 3
5 2011-09-24 15:06:52 3
6 2011-09-24 19:36:52 1
7 2011-09-24 20:36:52 7
8 2011-09-24 22:36:52 11
9 2011-09-26 20:36:52 12
如上,如何取得2011-09-24号,每个小时时段的SL总和?得到如下
11 4
14 2
15 6
19 1
20 7
22 11
------解决方案--------------------
SQL code
select hour(ADD_TIME),sum(SL)
from a
where ADD_TIME between '2011-09-24' and '2011-09-25'
group by hour(ADD_TIME)
------解决方案--------------------