关键点:利用TO_DAYS 来比较日期。 # Write your MySQL query statement belowSELECTw1.IdFROMWeather w1, Weather w2WHEREw1.Temperature>w2.TemperatureANDTO_DAYS(w1.RecordDate)-TO_DAYS(w2.RecordDate)=1; 参考资料:LeetCode Solution LeetCode 题目列表 -LeetCode Questions List...
https://leetcode.com/problems/rising-temperature/ 题目: AI检测代码解析 Given a Weather table, write a SQL query to find all dates’ Ids with higher temperature compared to its previous (yesterday’s) dates. +———+———+———+ | Id(INT) | Date(DATE) | Temperature(INT) | +——...
解法四: SELECTIdFROM(SELECTCASEWHENTemperature>@pre_tANDDATEDIFF(Date,@pre_d)=1THENIdELSENULLENDASId,@pre_t:=Temperature,@pre_d:=DateFROMWeather, (SELECT@pre_t:=NULL,@pre_d:=NULL)ASinitORDERBYDateASC) idWHEREIdISNOTNULL; 参考资料: https://leetcode.com/discuss/33641/two-solutions https...
fromWeatherasa,Weatherasb whereTO_DAYS(a.Date) +1 = TO_DAYS(b.Date)anda.Temperature < b.Temperature
Rising Temperature(上浮的温度) 2、题目地址 https://leetcode.com/problems/rising-temperature 3、题目内容 给出一组每日的气温数据,返回当日气温高于昨日气温的日期。 例如,Weather表中的数据如下: +---+---+---+ | Id(INT) | Date(DATE) | Temperature(INT)...
leetcode原文引用: Given aWeathertable, write a SQL query to find all dates' Ids with higher temperature compared to its previous (yesterday's) dates. +---+---+---+ | Id(INT) | Date(DATE) | Temperature(INT) | +---+---+---+ | 1 | 2015-01-01 | ...
[LeetCode][SQL]Rising Temperature Rising Temperature Given aWeathertable, write a SQL query to find all dates' Ids with higher temperature compared to its previous (yesterday's) dates. +---+---+---+ | Id(INT) | Date(DATE) | Temperature(INT...
➤GitHub地址:https://github.com/strengthen/LeetCode ➤原文地址:https://www.cnblogs.com/strengthen/p/10180555.html ➤如果链接不是山青咏芝的博客园地址,则可能是爬取作者的文章。 ➤原文已修改更新!强烈建议点击原文地址阅读!支持作者!支持原创!
https://leetcode.com/problems/rising-temperature/description/ 题目需要选出今天比昨天气温高的ID 用join,默认是inner join需要左右两边同时有才行。然后就是用on判断,首先判断其是相邻的两天。 用sql的DateDiff函数判断。 不知道为何用的和网上的结论相反 ...
+---+ | Id | +---+ | 2 | | 4 | +---+ 1 2 # Write your MySQL query statement below selectw1.IdfromWeather w1, Weather w2whereto_days(w1.RecordDate) = to_days(w2.RecordDate) + 1andw1.Temperature > w2.Temperature;