topic
Weather given a table, write a SQL query, to find higher before the date (yesterday) compared to the temperature Id all dates.
For example, according to the table given Weather, returns the following Id:
Resolve
Methods: JOIN and DATEDIFF () clause
algorithm
MySQL to compare the values of two types of dates using DATEDIFF.
Therefore, we can combine with the weather by itself, using the DATEDIFF () function.
MySQL
SELECT
weather.id AS 'Id'
FROM
weather
JOIN
weather w ON DATEDIFF(weather.date, w.date) = 1
AND weather.Temperature > w.Temperature
;
answer
SELECT
weather.id AS 'Id'
FROM
weather
JOIN
weather w ON DATEDIFF(weather.recorddate, w.recorddate) = 1
AND weather.Temperature > w.Temperature
;