本文主要是介绍【领扣leetcode数据库】197. 上升的温度 难度 简单,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
题目描述
给定一个 Weather
表,编写一个 SQL 查询,来查找与之前(昨天的)日期相比温度更高的所有日期的 Id。
+---------+------------------+------------------+ | 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 | +---------+------------------+------------------+
例如,根据上述给定的 Weather
表格,返回如下 Id:
+----+ | Id | +----+ | 2 | | 4 | +----+
代码
/* Write your T-SQL query statement below */
select a.id as id
from weather a
left join weather b
on datediff(day,b.recorddate,a.recorddate)=1
where a.temperature>b.temperature
这篇关于【领扣leetcode数据库】197. 上升的温度 难度 简单的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!