leetcode 197. Rising Temperature sql_Date用法
https://leetcode.com/problems/rising-temperature/description/
题目需要选出今天比昨天气温高的ID
用join,默认是inner join需要左右两边同时有才行。然后就是用on判断,首先判断其是相邻的两天。
用sql的DateDiff函数判断。
不知道为何用的和网上的结论相反
DateDiff(b, a) = 1表示b是a的下一天,才能ac
# Write your MySQL query statement below select b.Id as Id from Weather join (Weather as b) on DATEDIFF(b.Date, weather.Date) = 1 and b.Temperature > weather.Temperature;
既然选择了远方,就要风雨兼程~
posted on 2018-01-08 15:44 stupid_one 阅读(172) 评论(0) 收藏 举报
浙公网安备 33010602011771号