From e051ba74f5dbefc987825ed0dfd08c254b22ce39 Mon Sep 17 00:00:00 2001 From: Antim Pal <134076504+iamAntimPal@users.noreply.github.com> Date: Sat, 29 Mar 2025 12:29:27 +0530 Subject: [PATCH] Create Rising Temperature.sql --- .../Rising Temperature.sql | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LeetCode SQL 50 Solution/197. Rising Temperature/Rising Temperature.sql 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