Skip to content
We areTOP 1%

Rising Temperature

EasyLeetCodeSQL: CASE, String & Date Functions
Solve on LeetCode(opens in a new tab)
Track your progress
First attempt
Re-solve after a few days
Final pass before interviews
Hint and exampleShow

Join the table to itself on dates exactly one day apart, using DATEDIFF(a.day, b.day) = 1 in MySQL, then compare the two rows' values.

Example: sales(day, units)

day        | units
2024-03-01 | 10
2024-03-02 | 15
2024-03-03 | 12
SELECT t.day
FROM sales t
JOIN sales y ON DATEDIFF(t.day, y.day) = 1   -- PostgreSQL: t.day = y.day + 1
WHERE t.units > y.units;   -- returns 2024-03-02

More in SQL: CASE, String & Date Functions

Sign in to track your progress

Your checkboxes, streak and activity heatmap are saved to your account and sync across devices. It is free.
Sign in with email

New here? Create an account