[LeetCode] 197. Rising Temperature
2022. 6. 9. 22:23ㆍSQL
내 첫 쿼리
SELECT id
FROM (SELECT id
,recorddate
,temperature
,(LAG(temperature) OVER (ORDER BY id)) AS tem2
FROM weather) sub
WHERE (temperature-tem2)>0
완성 쿼리
SELECT w.id
FROM weather w
JOIN weather w1
ON DATEDIFF(w.recordDate,w1.recordDate) = 1
AND w.temperature > w1.temperature
조인 조건 ON에 DATEDIFF 함수 사용 가능
'SQL' 카테고리의 다른 글
[LeetCode] 180. Consecutive Numbers (0) | 2022.06.09 |
---|---|
[LeetCode] 1050. Actors and Directors Who Cooperated At Least Three Times (0) | 2022.06.09 |
[HackerRank] Weather Observation Station 5 (0) | 2022.06.08 |
[HackerRank] Weather Observation Station 3 (0) | 2022.06.07 |
[LeetCode] 178. Rank Scores (0) | 2022.06.07 |