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. DingTalk机器人C#代码

    前面已经介绍了机器人的事情,今天直接贴一下代码. using System; using System.Collections.Generic; using System.ComponentModel ...

  2. [学习笔记]_exit和exit深入理解

    #include<stdio.h> #include<stdlib.h> #include<string.h> #include <unistd.h> ...

  3. 如何破解IDEA

    https://blog.csdn.net/samery1020/article/details/79489164 http://idea.lanyus.com/ 我们在选择JAVA 使用IDEA时都 ...

  4. linux 定制

    转载至http://luyafei.blog.51cto.com/1092421/1131532 测试环境: VMware Workstation 8.0 CentOS 6.7 x86_64 1.安装 ...

  5. 「BZOJ 3242」「NOI 2013」快餐店「基环树」

    题意 基环树上找到一个点(可以在边上)使得它到树上最远点的距离最小,输出最小距离 题解 如果是一棵树,答案就是树的直径\(/2\) 如果是基环树,那么很好证明删去环上的某一条边是不影响答案的.于是断环 ...

  6. MyBatis的使用步骤及配置

    1.导入mybatis的jar包:mybatis-x.x.x.jar 2.使用XML配置mybatis,创建SqlSessionFactory XML配置文件的名称通常为mybatis-config. ...

  7. 安卓手机牛逼软件Termux中安装Archlinux,安装Jdk

    说出来你可能不信,手机上居然装了两个linux系统,和真实的linux有些许些差别. 首先安装了Termux以后你发现,好多linux常用功能都有,什么Pyhton,gcc,g++,ruby,Php, ...

  8. 加快 hive 查询的 5 种方法

    1. 使用 Tez set hive.execution.engine=tez; 2. 使用 ORCFILE.当有多个表 join 时,使用 ORCFile 进行存储,会显著地提高速度. CREATE ...

  9. 区块链中的密码学(二)-RSA算法分析和实现

    密码学领域中,加密算法主要分为对称加密和非对称加密,随着信息时代安全性要求越来越高,对称加密因为其易被破解的原因逐渐被舍弃.而RSA算法是目前密码学世界中比较流行的非对称加密算法,命名是根据其发明者R ...

  10. P1919 【模板】A*B Problem升级版(FFT快速傅里叶)

    题目描述 给出两个n位10进制整数x和y,你需要计算x*y. 输入输出格式 输入格式: 第一行一个正整数n. 第二行描述一个位数为n的正整数x. 第三行描述一个位数为n的正整数y. 输出格式: 输出一 ...