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 ...
随机推荐
- PhoneGap API介绍:File
本文将介绍PhoneGap API——File:通过JavaScript截获本地文件系统.File是用于读取.写入和浏览文件系统层次结构的PhoneGap API. 对象: DirectoryEntr ...
- ACE主动对象模式(1)
转载于:http://www.cnblogs.com/TianFang/archive/2006/12/11/589168.html 主动对象模式用于降低方法执行和方法调用之间的耦合.该模式描述了另外 ...
- 学习tcpIp必备的抓包工具wireshark
wireshark是一个优秀的抓包工具 ip.src=192.168.10.123 发送http的一端 ip.dst=192.168.10.126 接收http的一端 如下图所示:
- bzoj 1135 [POI2009]Lyz 线段树+hall定理
1135: [POI2009]Lyz Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 573 Solved: 280[Submit][Status][ ...
- Python学习笔记(Django篇)——3、创建第一个数据库模型
Django里面集成了SQLite的数据库,对于初期研究来说,可以用这个学习. 第一步,创建数据库就涉及到建表等一系列的工作,在此之前,要先在cmd执行一个命令: python manage.py ...
- Kubernetes - Start containers using Kubectl
In this scenario, you'll learn how to use Kubectl to create and launch Deployments, Replication Cont ...
- [LeetCode] string整体做hash key,窗口思想复杂度O(n)。附来自LeetCode的4例题(标题有字数限制,写不下所有例题题目 T.T)
引言 在字符串类型的题目中,常常在解题的时候涉及到大量的字符串的两两比较,比如要统计某一个字符串出现的次数.如果每次比较都通过挨个字符比较的方式,那么毫无疑问是非常占用时间的,因此在一些情况下,我们可 ...
- NOJ/HUST 1095 校赛 Just Go 线段树模板题
Description There is a river, which contains n stones from left to right. These stones are magic, ea ...
- Sass 条件-循环语句
学习Sass中 @if...@else @for @while @each 一.条件判断 - @if @else 示例: @mixin blockOrHidden($boolean:true){ @i ...
- node遇到的一些坑,npm无反应,cordova安装以后显示不是内部或外部命令
1.输入npm -v 以后一直无反应 C:\Users\用户名 目录下找到 .npmrc文件,删除以后,执行npm -v顺利显示版本号 2.安装cordova以后一直报错,不是内部或外部命令也不是可运 ...