https://leetcode.com/problems/rising-temperature/description/

题目需要选出今天比昨天气温高的ID

用join,默认是inner join需要左右两边同时有才行。然后就是用on判断,首先判断其是相邻的两天。

用sql的DateDiff函数判断。

不知道为何用的和网上的结论相反

DateDiff(b, a) = 1表示b是a的下一天,才能ac

# Write your MySQL query statement below
select b.Id as Id
from Weather join (Weather as b) on DATEDIFF(b.Date, weather.Date) = 1 and b.Temperature > weather.Temperature;

leetcode 197. Rising Temperature sql_Date用法的更多相关文章

  1. LeetCode 197. Rising Temperature (上升的温度)

    题目标签: 题目给了我们一个 温度表格,让我们找到 所有温度比之前一天高的,返回id. 建立 Weather w1, Weather w2,找到当w1 的温度 大于 w2 的时候,而且 w1 的日期是 ...

  2. Leetcode 197. Rising Temperature

    Given a Weather table, write a SQL query to find all dates' Ids with higher temperature compared to ...

  3. [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 ...

  4. [SQL]197. Rising Temperature

    Given a Weather table, write a SQL query to find all dates' Ids with higher temperature compared to ...

  5. 197. Rising Temperature

    Given a Weather table, write a SQL query to find all dates' Ids with higher temperature compared to ...

  6. [LeetCode] Rising Temperature 上升温度

    Given a Weather table, write a SQL query to find all dates' Ids with higher temperature compared to ...

  7. [SQL]LeetCode197. 上升的温度 | Rising Temperature

    SQL架构 Create table If Not Exists Weather (Id int, RecordDate date, Temperature int) Truncate table W ...

  8. DateBase -- Rising Temperature

    Question: Given a Weather table, write a SQL query to find all dates' Ids with higher temperature co ...

  9. LeetCode All in One 题目讲解汇总(持续更新中...)

    终于将LeetCode的免费题刷完了,真是漫长的第一遍啊,估计很多题都忘的差不多了,这次开个题目汇总贴,并附上每道题目的解题连接,方便之后查阅吧~ 477 Total Hamming Distance ...

随机推荐

  1. java全栈day08--面向对象

    今日内容介绍1.面向对象思想2.类与对象的二者关系3.局部变量和成员变量之间的关系4.封装的思想5.private,this关键字的用途6.案例 01面向对象和面向过程的思想 * A: 面向过程与面向 ...

  2. 错误页设置,设置HTTP状态码404,500(八)

    web.xml设置错误跳转(注意,路径必须以斜杠开头)  

  3. 一个android dex 转java源码工具

    和dex2jar,smali2java比起来,这个工具至少结果是正确的,前两者对于循环,异常等的处理明显逻辑就是错误的. 该小工具是基于androguard制作,本来是想自己写一个,后来一找居然有现成 ...

  4. onmouseover和onmouseout在GridView中应用 Ver2

    第一个版本,可以参考:http://www.cnblogs.com/insus/archive/2009/03/13/1411057.html 以前的版本,是在Gridview的OnRowCreate ...

  5. 正经学C#_运算符优先级:[c#入门经典]

    学了那么多的运算符,终于差不多结束了,现在要说一下  总体的优先级别 高到低的顺序 类别  运算符  结合性  前缀 ++,--,(),+,-,!,~ 从左到右  乘除  * / %  从左到右  加 ...

  6. JDK Linux下安装

    下载jdk-6u45-linux-x64.bin到/root目录下执行./jdk-6u45-linux-x64.bin 会在/root目录下生成 jdk1.6.0_45 文件 之后配置环境变量 编辑/ ...

  7. OC 语言新特性

    前言 相对于 Java,OC 语言是一门古老的语言了,而它又是一门不断发展完善的语言.一些新的编译特性,为 OC 语言带来了许多新的活力. 在 Xcode7 中,iOS9 的 SDK 已经全面兼容了 ...

  8. #学习笔记# VALSE 2019.01.09 朱俊彦 --- Learning to Synthesize Images, Videos, and 3D Objects

    视频类型:VALSE-webinar 报告时间:2019年01月09日 报告人:MIT朱俊彦 报告题目:Learning to Synthesize Images, Videos, and 3D Ob ...

  9. i++操作非原子的验证代码

    package incre; public class Incre { public static void main(String[] args) { class Count implements ...

  10. springboot开发环境搭建

    姓名:陈中娇   班级:软件151 第一步:在Eclipse下面配置Maven环境: 一.使用spring boot新建maven工程不在需要建立maven web工程,只要一般的maven工程就好了 ...