表Weather------------------------ | Column Name | Type | ------------------------ | id | int | | recordDate | date | | temperature | int | ------------------------ id 是该表具有唯一值的列。 没有具有相同 recordDate 的不同行。 该表包含特定日期的温度信息编写解决方案找出与之前昨天的日期相比温度更高的所有日期的id。返回结果无顺序要求。结果格式如下例子所示。示例 1输入Weather 表 ----------------------------- | id | recordDate | Temperature | ----------------------------- | 1 | 2015-01-01 | 10 | | 2 | 2015-01-02 | 25 | | 3 | 2015-01-03 | 20 | | 4 | 2015-01-04 | 30 | -----------------------------输出---- | id | ---- | 2 | | 4 | ----解释2015-01-02 的温度比前一天高10 - 25 2015-01-04 的温度比前一天高20 - 30难点:1.自我连接FROM Weather AS FIRST,Weather AS SECOND2.前一天的表达recordDate-INTERVAL 1 DAY# Write your MySQL query statement below SELECT FIRST.id FROM Weather AS FIRST,Weather AS SECOND WHERE SECOND.recordDateFIRST.recordDate-INTERVAL 1 DAYFIRST.temperatureSECOND.temperature;
高频 SQL 50题 197.上升的温度
表Weather------------------------ | Column Name | Type | ------------------------ | id | int | | recordDate | date | | temperature | int | ------------------------ id 是该表具有唯一值的列。 没有具有相同 recordDate 的不同行。 该表包含特定日期的温度信息编写解决方案找出与之前昨天的日期相比温度更高的所有日期的id。返回结果无顺序要求。结果格式如下例子所示。示例 1输入Weather 表 ----------------------------- | id | recordDate | Temperature | ----------------------------- | 1 | 2015-01-01 | 10 | | 2 | 2015-01-02 | 25 | | 3 | 2015-01-03 | 20 | | 4 | 2015-01-04 | 30 | -----------------------------输出---- | id | ---- | 2 | | 4 | ----解释2015-01-02 的温度比前一天高10 - 25 2015-01-04 的温度比前一天高20 - 30难点:1.自我连接FROM Weather AS FIRST,Weather AS SECOND2.前一天的表达recordDate-INTERVAL 1 DAY# Write your MySQL query statement below SELECT FIRST.id FROM Weather AS FIRST,Weather AS SECOND WHERE SECOND.recordDateFIRST.recordDate-INTERVAL 1 DAYFIRST.temperatureSECOND.temperature;