Write a solution to find all dates’ id with higher temperatures compared to its previous dates (yesterday).

Return the result table in any order.

Input
Weather =

idrecordDatetemperature
12015-01-0110
22015-01-0225
32015-01-0320
42015-01-0430

Output

id
2
4

记住!!不可以写 w.recordDate = y.recordDate+ 1 因为是日期,跨月份会找不出来!
要写 DATEDIFF(w.recordDate, y.recordDate) = 1

My solution:

SELECT w.id
FROM weather w
    JOIN weather y
        ON DATEDIFF(w.recordDate, y.recordDate) = 1
WHERE w.temperature > y.temperature

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部