Leetcode 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 |
+----+
思路:
TO_DAYS(date)可以将日期转换成公元后的天数。
# Write your MySQL query statement below
select w1.Id from Weather as w1, Weather as w2
WHERE TO_DAYS(w1.Date) = TO_DAYS(w2.Date) + 1 and w1.Temperature > w2.Temperature
Leetcode 197. Rising Temperature的更多相关文章
- 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 的日期是 ...
- [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 ...
- [SQL]197. Rising Temperature
Given a Weather table, write a SQL query to find all dates' Ids with higher temperature compared to ...
- 197. Rising Temperature
Given a Weather table, write a SQL query to find all dates' Ids with higher temperature compared to ...
- [LeetCode] Rising Temperature 上升温度
Given a Weather table, write a SQL query to find all dates' Ids with higher temperature compared to ...
- [SQL]LeetCode197. 上升的温度 | Rising Temperature
SQL架构 Create table If Not Exists Weather (Id int, RecordDate date, Temperature int) Truncate table W ...
- DateBase -- Rising Temperature
Question: Given a Weather table, write a SQL query to find all dates' Ids with higher temperature co ...
- LeetCode All in One 题目讲解汇总(持续更新中...)
终于将LeetCode的免费题刷完了,真是漫长的第一遍啊,估计很多题都忘的差不多了,这次开个题目汇总贴,并附上每道题目的解题连接,方便之后查阅吧~ 477 Total Hamming Distance ...
随机推荐
- L7,too late
words: parcel,包裹 detective,侦探 expect,期待 airfield,飞机起落的场地 guard,警戒,守卫,n precious,adj,珍贵的 stone,石头 exp ...
- Apache无法启动提示the requested operation has failed
主要参考这篇 http://apps.hi.baidu.com/share/detail/15868128 但还是遇到一些问题,记录如下: 1. 配置完成后,restart apache,出现 the ...
- 将项目同时托管到Github和Git@OSC
http://my.oschina.net/GIIoOS/blog/404555?fromerr=KHvn8UKH 摘要 Github是最大的git代码托管平台,GIT@OSC是国内最大的git代码 ...
- 表单提交中记得form表单放到table外面
帝国后台按栏目搜索文章时怎么都不生效 控制台查看原来是 栏目的select的值没有提交过去,原来由于form标签在table标签里面,导致js生成的<select>标签提交失败. 解决办 ...
- Block 再学习 !
如何优雅的使用 Block? How Do I Declare A Block in Objective-C? 阮一峰的一句话解释简洁明了:闭包就是能够读取其它函数内部变量的函数 详情:http:// ...
- 最新百度地图支持Fragment(注意事项)(转)
原文: 最新百度地图支持Fragment(注意事项) 开篇:老的百度地图通常都要继承MapActivity,这样不利于代码的可扩展性,再加上Fragment的流行,老的百度地图已经远远不能满足的大 ...
- linux操作命令实验
实验内容:文件操作与用户操作实验 实验设备(环境):电脑.Vmware WorkStation 实验步骤: 一.创建新用户bob 目的:练习useradd命令 二.为新用户bob设置口令 目的:练习p ...
- HDU 1260 Tickets(基础dp)
一开始我对这个题的题意理解有问题,居然超时了,我以为是区间dp,没想到是个水dp,我泪奔了.... #include<stdio.h> #include<string.h> # ...
- UCI
数据库是加州大学欧文分校(UniversityofCaliforniaIrvine)提出的用于机器学习的数据库,这个数据库目前共有187个数据集,其数目还在不断增加,UCI数据集是一个常用的标准测试数 ...
- 利用MyEclipse连接数据库并自动生成基于注解或者XML的实体类
一.利用MyEclipse连接数据库 1. 打开MyEclipse的数据库连接视图 然后在Other中找到"MyEclipse Database"中的DB Browser 2. 在 ...