Leecode SQL 197. Rising Temperature 日期差用 DATEDIFF()

Write a solution to find all dates' id with higher temperatures compared to its previous dates (yesterday).

Return the result table in any order.

Input

Weather =

id recordDate temperature
1 2015-01-01 10
2 2015-01-02 25
3 2015-01-03 20
4 2015-01-04 30

Output

id
2
4

记住!!不可以写 w.recordDate = y.recordDate+ 1 因为是日期,跨月份会找不出来!
要写 DATEDIFF(w.recordDate, y.recordDate) = 1

My solution:

sql 复制代码
SELECT w.id
FROM weather w
    JOIN weather y
        ON DATEDIFF(w.recordDate, y.recordDate) = 1
WHERE w.temperature > y.temperature
相关推荐
TDengine (老段)7 分钟前
TDengine IDMP 可视化 —— 分享
大数据·数据库·人工智能·时序数据库·tdengine·涛思数据·时序数据
GottdesKrieges1 小时前
OceanBase数据库备份配置
数据库·oceanbase
SPC的存折1 小时前
MySQL 8组复制完全指南
linux·运维·服务器·数据库·mysql
运维行者_1 小时前
OpManager MSP NetFlow Analyzer集成解决方案,应对多客户端网络流量监控挑战
大数据·运维·服务器·网络·数据库·自动化·运维开发
炸炸鱼.3 小时前
Python 操作 MySQL 数据库
android·数据库·python·adb
softshow10263 小时前
Etsy 把 1000 个 MySQL 分片迁进 Vitess
数据库·mysql
Ronaldinho Gaúch3 小时前
MySQL基础
数据库·mysql
不剪发的Tony老师4 小时前
Noir:一款键盘驱动的现代化数据库管理工具
数据库·sql
.柒宇.5 小时前
MySQL双主同步
linux·数据库·mysql·docker
Trouvaille ~5 小时前
【MySQL篇】数据类型:存储数据的基础
android·数据库·mysql·adb·字符集·数据类型·基础入门