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
相关推荐
xier_ran1 小时前
【infra之路】GPU 存储层次总结:L1 / L2 / HBM
java·网络·数据库
@insist1233 小时前
系统集成项目管理工程师-信息和文档管理
网络·数据库·软考·系统集成项目管理工程师·软考中项·软件水平考试
残 风5 小时前
PostgreSQL 存储机制详解
数据库·postgresql·开源·数据库开发
JacksonMx5 小时前
Java CompletableFuture 异步编程实战:从入门到架构师避坑指南
linux·数据库·python
tachibana26 小时前
性能指标的口径选择
数据库·人工智能·架构·大模型·llm
机器人梦想家6 小时前
具身机器人视觉服务的异步回调与并发控制
数据库·算法·机器人
小妖同学学AI7 小时前
开源向量数据库的王者:Milvus 深度解析,专为 AI 应用打造的云原生搜索引擎!
数据库·开源·milvus
l1258657 小时前
# RAG上线评估指标体系:六大核心指标与压测实战全解析
数据库·人工智能·python·mysql·langchain·milvus
一只鹿鹿鹿8 小时前
数据资产管理解决方案(Word文件)
大数据·数据库·安全·web安全·系统安全