当前位置:网站首页>Leetcode 197 Rising temperature (July 16, 2022)
Leetcode 197 Rising temperature (July 16, 2022)
2022-07-19 09:08:00 【ChaoYue_ miku】
SQL framework :
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')
surface : Weather
±--------------±--------+
| Column Name | Type |
±--------------±--------+
| id | int |
| recordDate | date |
| temperature | int |
±--------------±--------+
id It's the primary key of this table
The table contains temperature information for a specific date
Write a SQL Inquire about , To find out ( Yesterday's ) Of all dates with a higher temperature id .
Return results Order is not required .
The query result format is as follows .
Example 1:
Input :
Weather surface :
±—±-----------±------------+
| 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 |
±—+
explain :
2015-01-02 The temperature is higher than the day before (10 -> 25)
2015-01-04 The temperature is higher than the day before (20 -> 30)
source : Power button (LeetCode)
link :https://leetcode.cn/problems/rising-temperature
Method 1 : Use DATEDIFF()
MySQL Submission :
# Write your MySQL query statement below
SELECT w2.Id
FROM Weather w1, Weather w2
WHERE DATEDIFF(w2.RecordDate, w1.RecordDate) = 1
AND w1.Temperature < w2.Temperature
边栏推荐
- 使用<pre>和JSON.stringify处理网页展示JSON的格式
- Daily model series: July 11, 2022
- Development utility
- Understanding of user / Account / Account
- Megatexture technology of ID tech5
- [regression prediction] lithium ion battery life prediction based on particle filter with matlab code
- Towhee 每日模型周报
- [face recognition] face recognition based on histogram histogram with matlab code
- Exchange array elements without creating temporary variables
- Etcd database source code analysis -- etcdserver bootstrap recover store from snapshot
猜你喜欢
随机推荐
微信小程序调用API简单案例
Day 5 training
Cocos shader basics 7
[paper notes] Research on end positioning of grab manipulator based on multi-sensor data fusion
Latest fruit flstudio20.9 low version upgrade high version tutorial
mysql 初始化修改密码问题
【CTF】pwn2_ sctf_ two thousand and sixteen
数据湖(二十):Flink兼容Iceberg目前不足和Iceberg与Hudi对比
It's also very difficult. I'm not only tired of writing by myself
Jsp+servlet+mysql案例
Daily model series: July 11, 2022
数据库——sql-server
第七天训练
每日模型系列:2022.07.11
Redis
MySQL读写分离
Magic Usage of mongodb $symbol +mongo data type
Markdown(5):锚链接
Megatexture technology of ID tech5
Why are the special effects in others' games very soft








