Mysql刷题笔记 12.18 查找与之前(昨天的)日期相比温度更高的所有日期的 Id
作者:互联网
Mysql练习
T1218
+------+------------+------+
| ID | REDATE | TEMP |
+------+------------+------+
| 1 | 2020-01-01 | 10 |
| 2 | 2020-01-02 | 18 |
| 3 | 2020-01-03 | 15 |
| 4 | 2020-01-04 | 20 |
+------+------------+------+
结果:
+------+
| ID |
+------+
| 2 |
| 4 |
+------+
-- 重点是DATE_ADD()和INTERVAL 1 DAY
select b.ID from T1218 a
inner join T1218 b
on DATE_ADD(a.REDATE,INTERVAL 1 day) = b.REDATE
and a.TEMP < b.TEMP
标签:REDATE,01,+------+,TEMP,+------+------------+------+,日期,2020,Mysql,刷题 来源: https://blog.csdn.net/qq_30031221/article/details/111357925