Copy Create table If Not Exists Weather (Id int , RecordDate date , Temperature int )
Truncate table Weather
insert into Weather (Id, RecordDate, Temperature) values ( ' 1 ' , ' 2015-01-01 ' , ' 10 ' )
insert into Weather (Id, RecordDate, Temperature) values ( ' 2 ' , ' 2015-01-02 ' , ' 25 ' )
insert into Weather (Id, RecordDate, Temperature) values ( ' 3 ' , ' 2015-01-03 ' , ' 20 ' )
insert into Weather (Id, RecordDate, Temperature) values ( ' 4 ' , ' 2015-01-04 ' , ' 30 ' ) +---------+------------------+------------------+ | Id(INT) | RecordDate(DATE) | Temperature(INT) | +---------+------------------+------------------+ | 1 | 2015-01-01 | 10 | | 2 | 2015-01-02 | 25 | | 3 | 2015-01-03 | 20 | | 4 | 2015-01-04 | 30 | +---------+------------------+------------------+
+----+ | Id | +----+ | 2 | | 4 | +----+
Copy select a.id
from weather as a join weather as b
on datediff(a.recorddate, b.recorddate)=1 and a.temperature > b.temperature Runtime: 398 ms, faster than 41.07% of MySQL online submissions forRising Temperature.
Memory Usage: N/A
Runtime: 886 ms, faster than 6.73% of MySQL online submissions forRising Temperature.
Memory Usage: N/A
Runtime: 337 ms, faster than 66.03% of MySQL online submissions forRising Temperature.
Memory Usage: N/A
In MySQL, JOIN, CROSS JOIN, and INNER JOIN are syntactic equivalents (they can replace each other). In standard SQL, they are not equivalent. INNER JOIN is used with an ON clause, CROSS JOIN is used otherwise.