Problem
Given a Weather table, write a SQL query to find all dates’ Ids with higher temperature compared to its previous (yesterday’s) dates.
1 | |
For example, return the following Ids for the above Weather table:
1 | |
Explanation
- We can use
INNER JOINtwo tables. The relationship between these two table are the first table has higher temperature than the second table’s temperature, and we can useDATEDIFFto get the difference between these two table’s date, and the difference must be 1.
Solution
1 | |