MySQL:GROUP BY特定时间段(重叠天数)

MySQL: GROUP BY specific time periods (overlapping days)

我有一个 table,以 5 分钟为周期存储多年的天气数据。现在我需要一个最低温度的结果,从晚上 8 点到第二天早上 8 点的每个时间段。

或者换句话说:每晚 (20:00 - 08:00) 的最低温度。

Table:

datetime            temp
2015-04-01 00:00    21.2
2015-04-01 00:05    21.1
2015-04-01 00:10    20.8
...
2015-04-02 00:00    22.6
2015-04-02 00:05    22.2

我最基本的方法是:

SELECT MIN(temp) 
FROM weathertable 
WHERE datetime BETWEEN '2015-04-01 18:00' AND '2015-04-02 08:00'

但我需要每个没有固定日期的时间段的结果。

感谢帮助

试试这个:

获取前一个日期:select subdate(curdate(),1);

SELCT min(temp) 
FROM *tablename*
where 
date between 
concat(subdate(curdate(),1),' ','20:00:00') and concat(curdate(),' ','08:00:00');
SELECT 
   MIN(temp)
FROM 
   weathertable
WHERE 
    TIME(FROM_UNIXTIME(UNIX_TIMESTAMP(datetime)-(10*60*60))) BETWEEN '08:00:00' AND '22:00:00'
GROUP BY 
    DATE(FROM_UNIXTIME(UNIX_TIMESTAMP(datetime)-(10*60*60)));