记录最近一小时,比如10点多累计10点到11点的,11点又从0开始累计11点到12点的
selsct*from 表名
select * from table where to_char(时间字段,'hh24') = to_char(sysdate,'hh24')
不就是时间在10点多的时候统计10:00-10.59的数据吗?那就是判断小时数相等的数据就取出来,如果还要判断日期就是
to_char(sysdate,'yyyy-mm-dd hh24')
where 时间 between 当前时间精确到小时 and 当前时间当前时间精确到小时+1
不知道你的数据库是啥,仅供参考
开窗函数-逐层累计-http://help.finereport.com/finereport9.0/doc-view-1960.html
逐层累计-https://help.fanruan.com/finereport/doc-view-348.html
======
SQL端就用开窗函数实现,报表端用层次坐标实现,文档都有讲解;
between 当前小时0分 and 下个小时0分
或者 小时数=当前小时数
不同数据库,语法不一样,看数据库的把。
比如oracle
where to_char(时间,'yyyy-mm-dd hh24:')=to_char(sysdate,'yyyy-mm-dd hh24:')
你是想实时查询最近一个小时的,还是想以一个小时的分组查询出来