728x90
데이터 타입이 date라는 점을 주목하자
Select w1.id
from weather w1 join weather w2
on w1.recorddate = date_add(w2.recorddate, interval +1 day)
where w1.temperature > w2.temperature
date_add()
Add n days to a date and return the date
select *로 출력해보면
{"headers": ["Id", "RecordDate", "Temperature", "Id", "RecordDate", "Temperature"],
"values": [[2, "2015-01-02", 25, 1, "2015-01-01", 10],
[3, "2015-01-03", 20, 2, "2015-01-02", 25],
[4, "2015-01-04", 30, 3, "2015-01-03", 20]]}
on 부분
w1.recorddate과 date_add(w2.recorddate, interval +1 day)이 참인
즉, w1=w2 이기 때문에 w2에 +1 day한 w1의 행들만 선택.
where문은 별거 없기 때문에 pass
728x90
'SQL' 카테고리의 다른 글
[LeetCode] Not Boring Movies (0) | 2021.04.09 |
---|---|
[LeetCode] Classes More Than 5 Students (group by, having, count, distinct) (0) | 2021.04.09 |
[LeetCode] Delete Duplicate Emails (delete, self join, and) (0) | 2021.04.09 |
[LeetCode] Customes Who Never Order (is null, join) (0) | 2021.04.09 |
[LeetCode] Duplicate Emails (group by, having) (0) | 2021.04.09 |
댓글