力扣-数据库2

题目:给定一个 Weather 表,编写一个 SQL 查询,来查找与之前(昨天的)日期相比温度更高的所有日期的 Id。

解题

1
select w1.Id from Weather w1 join Weather w2 on DATEDIFF(w1.RecordDate, w2.RecordDate) = 1 and w1.Temperature>w2.Temperature

DATEDIFF的使用说明:

可以参考:http://www.360doc.com/content/15/0921/15/110467_500515921.shtml