출처 : LeetCode Rising Temperature
Table
Weather
Column Name Type id int recordDate date temperature int id is the column with unique values for this table.
There are no different rows with the same recordDate.
This table contains information about the temperature on a certain day.
Q.
Write a solution to find all dates
idwith higher temperatures compared to its previous dates (yesterday).
Return the result table in any order.
The result format is in the following example.

어제보다 기온이 더 높았던 날짜의 id를 찾는 문제
주의!!
내 답안 📕
WITH new_temp AS (
SELECT *
, LAG(temperature, 1) OVER(ORDER BY recordDate) AS yesterday_temp
, DATEDIFF(recordDate, LAG(recordDate, 1) OVER(ORDER BY recordDate)) AS date_diff
FROM Weather
)
SELECT id AS 'Id'
FROM new_temp
WHERE temperature > yesterday_temp
AND date_diff = 1