๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
  • ๐Ÿ‘ฉ๐Ÿปโ€๐Ÿ’ป ๐ŸŒฎ ๐Ÿ’ฌ
๐Ÿ’ป leetcode/database

[LeetCode] Database | 197. Rising Temperature

by ๋ฐ”์ฟ„๋ฆฌ 2022. 1. 12.

Problem


Example


 

Thinking


์ด๋ฒˆ์— ๋ฐฐ์šด ํ•จ์ˆ˜๊ฐ€ ์žˆ๋‹ค DATEDIFF

 

DATEDIFF(date1, date2) ๋Š” ๊ณง date1 - date2 ์ด๋‹ค

์œ„์˜ ๋ฌธ์ œ์—์„œ๋Š” ๋‹ค์Œ๋‚ ์˜ ๋ฐ์ดํ„ฐ์™€ ๋น„๊ต๋ฅผ ํ•ด์•ผํ•˜๋Š” ๊ฒƒ์ด๋‹ˆ ํ•˜๋ฃจ ์ฐจ์ด์ด๋‹ค.

๊ทธ๋Ÿผ DATEDIFF(today.recordDate, yesterday.recordDate) = 1 ์ด๋ผ๊ณ  ์ ์–ด์ค„ ์ˆ˜ ์žˆ๋‹ค. 

 

Solve


์ œ์ถœ ๋‹ต์•ˆ

 

SELECT today.id
    FROM Weather AS today
    JOIN Weather AS yesterday ON DATEDIFF(today.recordDate, yesterday.recordDate) = 1
    WHERE today.temperature > yesterday.temperature


 

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

 

Rising Temperature - LeetCode

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com