197. Rising Temperature
Given a Weather
table, write a SQL query to find all dates' Ids with higher temperature compared to its previous (yesterday's) dates.
+---------+------------+------------------+
| Id(INT) | Date(DATE) | Temperature(INT) |
+---------+------------+------------------+
| 1 | 2015-01-01 | 10 |
| 2 | 2015-01-02 | 25 |
| 3 | 2015-01-03 | 20 |
| 4 | 2015-01-04 | 30 |
+---------+------------+------------------+
For example, return the following Ids for the above Weather table:
+----+
| Id |
+----+
| 2 |
| 4 |
+----+ 查找与昨天的日期相比更高的日期的id。 MySQL(1868ms):
SELECT w1.Id
FROM Weather w1 , Weather w2
WHERE w1.Temperature > w2.Temperature
AND TO_DAYS(w1.Date) - TO_DAYS(w2.Date) = 1 ;
197. Rising Temperature的更多相关文章
- Leetcode 197. Rising Temperature
Given a Weather table, write a SQL query to find all dates' Ids with higher temperature compared to ...
- [SQL]197. Rising Temperature
Given a Weather table, write a SQL query to find all dates' Ids with higher temperature compared to ...
- leetcode 197. Rising Temperature sql_Date用法
https://leetcode.com/problems/rising-temperature/description/ 题目需要选出今天比昨天气温高的ID 用join,默认是inner join需 ...
- LeetCode 197. Rising Temperature (上升的温度)
题目标签: 题目给了我们一个 温度表格,让我们找到 所有温度比之前一天高的,返回id. 建立 Weather w1, Weather w2,找到当w1 的温度 大于 w2 的时候,而且 w1 的日期是 ...
- [SQL]LeetCode197. 上升的温度 | Rising Temperature
SQL架构 Create table If Not Exists Weather (Id int, RecordDate date, Temperature int) Truncate table W ...
- [LeetCode] Rising Temperature 上升温度
Given a Weather table, write a SQL query to find all dates' Ids with higher temperature compared to ...
- [LeetCode] 197. Rising Temperature_Easy tag: SQL
Given a Weather table, write a SQL query to find all dates' Ids with higher temperature compared to ...
- DateBase -- Rising Temperature
Question: Given a Weather table, write a SQL query to find all dates' Ids with higher temperature co ...
- sql_自连接,181,182,196,197
181. Employees Earning More Than Their Managers https://leetcode.com/problems/employees-earning-more ...
随机推荐
- 【二分】【P1314】 【NOIP2011D2T2】聪明的质监员
传送门 Description 小T 是一名质量监督员,最近负责检验一批矿产的质量.这批矿产共有 \(n\) 个矿石,从 \(1\) 到 \(n\) 逐一编号,每个矿石都有自己的重量 \(w_i\) ...
- springboot的application.properties与.yml的区别
现在我们的application.properties文件内容是: server.port=8090 server.session-timeout=30 server.context-path= se ...
- JavaScript知识之判断字符串中出现最多的字符及次数
var str = 'asdddasdfdseeeeeweeeeeeeeeeeee'; var json = {}; // 定义json一个对象 for(var i = 0; i < str.l ...
- 【Android】完善Android学习(四:API 3.1)
备注:之前Android入门学习的书籍使用的是杨丰盛的<Android应用开发揭秘>,这本书是基于Android 2.2API的,目前Android已经到4.4了,更新了很多的API,也增 ...
- svn全备加强版
svn版本库备份 官方建议使用如下方法备份(全备) svnadmin hotcopy path/to/repository path/to/backup 链接:https://tortoisesvn. ...
- truncate与delete以及drop
truncate:删除整个表,但不删除定义(删除了整个表的数据,但表结构还在) drop:删除整个表,表数据和表结构都删除了 delete:删除表中数据 比较delete和drop 1.truncat ...
- Informatica _组件使用介绍及优化
转载 http://blog.csdn.net/yongjian1092/article/details/52588434 有空自己会写一个关于这方面的文章.
- btrace 常见问题
执行btrace命令报错:Unable to open socket file: target process not responding or HotSpot VM not loaded ---- ...
- 【Luogu】P3933 Chtholly Nota Seniorious
[题意]将n*m矩阵分成两个区域,要求满足一定条件,求两区域内部极差较大值最小.n,m<=2000 [算法]二分 [题解]极差的数值满足单调性,所以考虑二分极差. 对于给定的极差,将所有数值排序 ...
- OPENId是什么, OAUTH 是什么
what is openId open id is said to be a protocol which uses url as username, so if a website supports ...