[leetcode]197. Rising Temperature

김준석·2024년 2월 5일

코딩테스트 - SQL

목록 보기
63/96

문제

https://leetcode.com/problems/rising-temperature/description/?envType=study-plan-v2&envId=top-sql-50

어제보다 온도가 높은 id 출력

코드

SELECT
    w1.id
FROM
    Weather w1
    INNER JOIN Weather w2
        ON w1.recordDate = ADDDATE(w2.recordDate,1)
WHERE 1=1
    AND w1.temperature >w2.temperature

풀이 후기

해당 문제는 row에 어제, 오늘에 대한 정보를 만들어야 된다.
그렇기 때문에 self join을 진행.

0개의 댓글