Rising Temperature
EasyLeetCodeSQL: CASE, String & Date Functions
Hint and exampleShowHide
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
| # | Problem | Platform | Difficulty | Open | 1st1st Visit | 2nd2nd Visit | RevRevise |
|---|---|---|---|---|---|---|---|
| 1 | Triangle Judgement | LeetCode | Easy | Solve Triangle Judgement on LeetCode (opens in a new tab) | |||
| 2 | Fix Names in a Table | LeetCode | Easy | Solve Fix Names in a Table on LeetCode (opens in a new tab) | |||
| 3 | Rising Temperature | LeetCode | Easy | Solve Rising Temperature on LeetCode (opens in a new tab) | |||
| 4 | Group Sold Products By The Date | LeetCode | Easy | Solve Group Sold Products By The Date on LeetCode (opens in a new tab) | |||
| 5 | Monthly Transactions I | LeetCode | Medium | Solve Monthly Transactions I on LeetCode (opens in a new tab) | |||
| 6 | Confirmation Rate | LeetCode | Medium | Solve Confirmation Rate on LeetCode (opens in a new tab) |