表Weather:
id | recordDate | Temperature |
---|---|---|
1 | 2015-01-01 | 10 |
1 | 2015-01-02 | 25 |
1 | 2015-01-03 | 20 |
1 | 2015-01-04 | 30 |
思路分析:
使用MySQL DATEDIFF() 函数
MySQL语句:
select w1.id as ‘Id’ from Weather w1 join Weather w2 on DATEDIFF(w1.recordDate,w2.recordDate) = 1 and w1.temperature > w2.temperature;
注:MySQL DATEDIFF() 函数
定义和用法
DATEDIFF() 函数返回两个日期之间的天数。
语法
DATEDIFF(date1,date2)
date1 和 date2 参数是合法的日期或日期/时间表达式。
注释:只有值的日期部分参与计算。