LeetCode刷题实战197:上升的温度
程序IT圈
共 1213字,需浏览 3分钟
·
2021-03-01 13:55
Write an SQL query to find all dates' id with higher temperature compared to its previous dates (yesterday).
Return the result table in any order.
题意
解题
select w1.Id as Id
from Weather w1
#连接Weather表(自连接)
inner join Weather w2
#连接条件,w2是w1的前一天
on datediff(w1.RecordDate, w2.RecordDate) = 1
#筛选条件:温度升高
where w1.Temperature > w2.Temperature;
评论