DATEDIFF
函数用于计算两个日期之间的差值,以天为单位
DATEDIFF
函数返回一个整数,表示date1
和date2
之间的天数。如果date1
在date2
之前,结果为负数;如果在date2
之后,结果为正数;如果相等,则结果为零。
SELECT t.id
FROM Weather AS t
JOIN Weather AS y
ON DATEDIFF(t.recordDate, y.recordDate) = 1
WHERE t.temperature > y.temperature;
SELECT t.id
FROM Weather AS t,Weather AS y
WHERE DATEDIFF(t.recordDate, y.recordDate) = 1ANDt.temperature > y.temperature;