上升的温度

问题描述(来源于LeetCode)

表: Weather

±--------------±--------+
| Column Name | Type |
±--------------±--------+
| id | int |
| recordDate | date |
| temperature | int |
±--------------±--------+
id 是该表具有唯一值的列。
没有具有相同 recordDate 的不同行。
该表包含特定日期的温度信息

编写解决方案,找出与之前(昨天的)日期相比温度更高的所有日期的 id 。

返回结果 无顺序要求 。

代码实现

1
2
3
4
5
6
# Write your MySQL query statement below
SELECT t2.id AS Id
FROM Weather t1
CROSS JOIN Weather t2
ON DATEDIFF(t1.recordDate,t2.recordDate)=-1
WHERE t2.Temperature>t1.Temperature