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) = 1
AND
t.temperature > y.temperature;

2241

被折叠的 条评论
为什么被折叠?



