DB2 数据库按时间统计条数的语句,跪求!
表里有date,time 两个字段,此表内大概有30万条数据,我想统计每分钟有多少数据?用select * from xxx where date = '2009-5-5' and ftime > 'xx:xx:xx' and ftime <= 'xx:xx:xx'统计太繁琐,
请问有什么好的办法?非常感谢!
FDATE ftime
2009-5-5 10:00:01
2009-5-5 10:00:02
2009-5-5 10:00:03
2009-5-5 10:00:04
2009-5-5 10:00:05
2009-5-5 10:00:06
2009-5-5 10:00:07
2009-5-5 10:00:08
2009-5-5 10:00:09
2009-5-5 10:00:10
2009-5-5 10:00:11
............................
.............................
............... select fdate,(char(hour(ftime)) || ':' || char(minute(ftime))) ftime ,count(*) from tab group by fdate,ftime 很简单,用substr加group by
db2 "select substr(char(ftime),3,2),count(*) from table group by substr(char(ftime),3,2) order by count(*)"
页:
[1]