这题主要记录一下datediff和date_add的用法
DATEDIFF() 函数返回两个日期(date1-date2)之间间隔的天数/年数等,如:
DateDiff(timeinterval,date1,date2)
SELECT w2.Id
FROM Weather AS w1
INNER JOIN Weather AS w2
ON DATEDIFF(w2.RecordDate, w1.RecordDate) = 1
AND w1.Temperature < w2.Temperature
这里的timeinterval还有很多,也可以省略
DATE_ADD()是指函数向日期添加指定的时间间隔
SELECT w2.Id
FROM Weather AS w1
INNER JOIN Weather AS w2
ON DATE_ADD(w1.RecordDate, INTERVAL 1 DAY) = w2.RecordDate
AND w1.Temperature < w2.Temperature