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. MySQL中的时间问题

    MySQL 获得当前日期时间 函数 获得当前日期+时间(date + time)函数:now() mysql> select now(); +---------------------+ | n ...

  2. WordCount编码与测试

    1. github项目地址:https://github.com/wwwwu/WordCount 2.PSP表格: PSP2.1 PSP阶段 预估耗时 (分钟) 实际耗时 (分钟) Planning ...

  3. 在robotframework里面,怎么在已有的字典中加一个键值对呢

  4. SQL/T-SQL实例参考-1

    CASE ,D.[Score] B_Score ,'Distince'= CASE WHEN C.Score > D.Score THEN C.[Score] - D.[Score] WHEN ...

  5. 线程池ThreadPool实现异步多线程

    ThreadPool线程池的主要方法: 1. public static Boolean QueueUserWorkItem(WaitCallback wc, Object state); WaitC ...

  6. STM32单片机串口中断+DMA使用(含CUBE配置)

    最近又要重新用32做点东西,发现一两年没怎么碰的结果就是,曾经熟得不行的东西都变得极度陌生,这种重新学习记忆的过程过于痛苦,果然还是要留下一些记录给之后失忆的自己的. 1.STM32CUBE配置 1. ...

  7. Python3中简单的迭代器程序

    1.迭代器程序(实现菲比那次数列并且可以抛出与接收异常) def fib(max): n,a,b = 0,0,1 while n < max: #print(b) yield b a,b = b ...

  8. VirtualBox 5.0(虚拟机软件)里,安装Fedora遇到的问题!!

    问题一: 安装完毕后,重新启动竟然还是进入了Fedora安装过程里. 问题原因:Fedora,并没有处理安装时候加载的ISO文件,依旧让VirtualBox 5.0运行它. 解决方法:在运行Fedor ...

  9. MariaDB之SQL语句基础

    数据库组件: 数据库:database 表: table 索引:index 视图:view 用户:user 权限:privileges 存储过程:procedure 存储函数:function 触发器 ...

  10. boost库checked_delete的使用

    在查看boost库时发现一个小文件checked_delete.hpp里面几个小函数,它的作用用很简短的话来说:防止未定义的行为造成delete时的内存泄露.实现如下: template<cla ...