Given a Weather table, write a SQL solution to find all dates' id with higher temperatures compared to their previous dates (yesterday).
The Weather table contains information about the temperature on a certain day. Each record has a unique id and there are no different rows with the same recordDate.
Return the result table in any order.
Table Schema
| Column Name | Type | Description |
|---|---|---|
id
PK
|
int | Primary key, unique identifier for each weather record |
recordDate
|
date | Date of the temperature record |
temperature
|
int | Temperature recorded on that date |
Input & Output
| id | recordDate | temperature |
|---|---|---|
| 1 | 2015-01-01 | 10 |
| 2 | 2015-01-02 | 25 |
| 3 | 2015-01-03 | 20 |
| 4 | 2015-01-04 | 30 |
| id |
|---|
| 2 |
| 4 |
ID 2 (2015-01-02) has temperature 25°, which is higher than the previous day's temperature of 10°. ID 4 (2015-01-04) has temperature 30°, which is higher than the previous day's temperature of 20°. ID 3 doesn't qualify because 20° < 25°.
| id | recordDate | temperature |
|---|---|---|
| 1 | 2015-01-01 | 30 |
| 2 | 2015-01-02 | 25 |
| 3 | 2015-01-03 | 20 |
| id |
|---|
No dates have higher temperatures than their previous dates. The temperature consistently decreases: 30° → 25° → 20°, so no records are returned.
Constraints
-
1 ≤ Weather.id ≤ 100 -
recordDateis a valid date -
-100 ≤ temperature ≤ 100 -
All
recordDatevalues are unique