LeetCode - Rising Temperature

  Description:Given a Weather table, write a SQL query to find all dates' Ids with higher temperature compared to its previous (yesterday's) dates.

  选出比前一天温度高的Id

  使用自连接,to_days函数是返回从零年开始的总天数。

  (为何把=误写成<会Runtime Error啊 不应该是WrongAnser!)

  

# Write your MySQL query statement below
select w2.Id from Weather w1, Weather w2
where to_days(w1.Date)+1=to_days(w2.Date) and w1.Temperature<w2.Temperature;

 

posted @ 2015-04-19 23:01  Pickle  阅读(274)  评论(0编辑  收藏  举报