LeetCode 197. Rising Temperature (temperature rise)

Topic Tags:

  The title gives us a temperature table, let us one day to find all temperature higher than before, return id.

  Establish Weather w1, Weather w2, w2 find the time when the temperature is higher than the w1, w1 and w2 date is after one day, return id.

 

Java Solution:

Runtime:  338 ms, faster than 66 % 

Memory Usage: N/A

Completion Date: 06/01/2019

Key point: use to compare dates TO_DAYS.

# Write your MySQL query statement below
SELECT w1.Id 
FROM Weather w1, Weather w2
WHERE w1.Temperature > w2.Temperature AND 
      TO_DAYS(w1.RecordDate)-TO_DAYS(w2.RecordDate)=1;

Reference: LeetCode Solution

LeetCode title list -  LeetCode Questions List

Topic Source: https: //leetcode.com/

Guess you like

Origin www.cnblogs.com/jimmycheng/p/11444498.html