<aside> 💡
This project identifies dates where the temperature was higher than the previous day. The solution demonstrates SQL techniques like self-joins and date difference calculations.
</aside>
The task is to find the ids of dates where the temperature was higher compared to the previous day.
The query uses a self-join on the Weather table to compare each date's temperature with the temperature of the previous day.
SELECT W2.id
FROM Weather W1
JOIN Weather W2
ON DATEDIFF(W2.recordDate, W1.recordDate) = 1
WHERE W2.temperature > W1.temperature;
JOIN Weather W2 ON DATEDIFF(W2.recordDate, W1.recordDate) = 1 pairs each record with the one from the previous day (recordDate - 1).WHERE W2.temperature > W1.temperature ensures only records where the temperature increased are included.SELECT W2.id retrieves the id of dates where the temperature was higher than the previous day.