Description

Write a SQL query to find all dates where the temperature was higher than the previous day. Return the id of those records. **Output columns (in order):** id

Table:weather
ColumnType
idINT
dateTEXT
temperatureINT

Examples

Input:CREATE TABLE weather (id INT, date TEXT, temperature INT); INSERT INTO weather VALUES (1, '2024-01-01', 10), (2, '2024-01-02', 15), (3, '2024-01-03', 12), (4, '2024-01-04', 20);
Output:2 4
Explanation:

Day 2 (15°) was warmer than day 1 (10°), and day 4 (20°) was warmer than day 3 (12°). Day 3 was colder than day 2, so it doesn't qualify.

Input:CREATE TABLE weather (id INT, date TEXT, temperature INT); INSERT INTO weather VALUES (1, '2024-02-01', 25), (2, '2024-02-02', 22), (3, '2024-02-03', 28), (4, '2024-02-04', 30), (5, '2024-02-05', 18);
Output:3 4
Explanation:

Day 3 (28°) was warmer than day 2 (22°), and day 4 (30°) was warmer than day 3 (28°). Day 2 had lower temperature than day 1, and day 5 had much lower temperature than day 4, so they don't qualify.

Input:CREATE TABLE weather (id INT, date TEXT, temperature INT); INSERT INTO weather VALUES (1, '2024-03-10', 8), (2, '2024-03-11', 8), (3, '2024-03-12', 12), (4, '2024-03-13', 7), (5, '2024-03-14', 9);
Output:3 5
Explanation:

Day 3 (12°) was warmer than day 2 (8°), and day 5 (9°) was warmer than day 4 (7°). Day 2 had the same temperature as day 1 (no increase), and day 4 was colder than day 3, so they don't qualify.

Constraints

  • Compare with previous day

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!