如何在时间戳列中选择每n小时?我可以通过分组1小时这样做:
SELECT log_timestamp FROM log GROUP BY DATE( log_timestamp ), HOUR( log_timestamp )
返回:
log_timestamp 2015-11-08 00:00:01 2015-11-08 01:00:01 2015-11-08 02:00:01 2015-11-08 03:00:01 ...
有关如何执行2小时或更长时间的任何想法?
log_timestamp 2015-11-08 00:00:01 2015-11-08 02:00:01 2015-11-08 04:00:01 2015-11-08 06:00:01 ...
Lukasz Szozd.. 6
你可以使用INTEGER DIVISION
:
SELECT L.log_timestamp FROM log L GROUP BY DATE( log_timestamp ), hour( log_timestamp ) DIV 2
SqlFiddleDemo
你可以使用INTEGER DIVISION
:
SELECT L.log_timestamp FROM log L GROUP BY DATE( log_timestamp ), hour( log_timestamp ) DIV 2
SqlFiddleDemo