diff --git a/LeetCode SQL 50 Solution/197. Rising Temperature/Rising Temperature.sql b/LeetCode SQL 50 Solution/197. Rising Temperature/Rising Temperature.sql new file mode 100644 index 0000000..72b2d7f --- /dev/null +++ b/LeetCode SQL 50 Solution/197. Rising Temperature/Rising Temperature.sql @@ -0,0 +1,21 @@ +"""197. Rising Temperature""" + +WITH PreviousWeatherData AS +( + SELECT + id, + recordDate, + temperature, + LAG(temperature, 1) OVER (ORDER BY recordDate) AS PreviousTemperature, + LAG(recordDate, 1) OVER (ORDER BY recordDate) AS PreviousRecordDate + FROM + Weather +) +SELECT + id +FROM + PreviousWeatherData +WHERE + temperature > PreviousTemperature +AND + recordDate = DATE_ADD(PreviousRecordDate, INTERVAL 1 DAY); \ No newline at end of file