何かやってみるブログ

興味をもったこと、趣味のこと、技術について色々書きます。

LeetCode Rising Temperatureを解いてみた

問題

https://leetcode.com/problems/rising-temperature/

解いた

SELECT
    WWW.id
FROM
    (
        SELECT
            WW.id,
            W.temperature AS 'pre_temp',
            WW.temperature AS 'today_temp'
        FROM
            Weather AS W,
            Weather AS WW
        WHERE
            DATEDIFF(WW.recordDate, W.recordDate) = 1
        ORDER BY W.recordDate ASC
    ) AS WWW
WHERE 
 pre_temp < today_temp

結果

f:id:s-takaya1027:20220313063612p:plain