leetcode 197. Rising Temperature sql_Date用法
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用法的更多相关文章
- LeetCode 197. Rising Temperature (上升的温度)
题目标签: 题目给了我们一个 温度表格,让我们找到 所有温度比之前一天高的,返回id. 建立 Weather w1, Weather w2,找到当w1 的温度 大于 w2 的时候,而且 w1 的日期是 ...
- Leetcode 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_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 ...
随机推荐
- kafka的producer执行卡住的问题
使用windows开发producer然后向远程的kakfa集群发送数据,但是一直卡着, 在window的hosts文件添加kafka集群的主机名和ip的映射就好了 网上搜了下,大致是producer ...
- 使用docker的kms服务器激活office2016专业增强版
我安装了office2016专业增强版,使用自己搭建的kms激活服务器无法激活,回来使用了一下脚本: 感谢,rainfarm的博主.博客地址:http://blog.sina.com.cn/s/blo ...
- c# 汉字换英文,英文转汉字
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- Spring MVC 简介
- jQuery实例代码-表单相关
select option 获取选中项的文本值 $("#ddl_GoOutReasonType option:selected").text() 根据索引定于option项 $(& ...
- 第一个HelloWorld!
$.介绍 1.eclipse的基本使用 2.第一个程序HelloWorld 3.总结 $.基本使用 对于刚入门的java新手来说选择一个舒适的编译器能让你快速的上手java的程序编写. 针对英语low ...
- 一道面试题关于js中添加动态属性
js中数据类型包含基本数据类型和引用类型,基本类型包括:string.null.undefined.number.boolean.引用类型即是对象比如:array .function以及自定义对象等 ...
- 【bzoj2186】: [Sdoi2008]沙拉公主的困惑 数论-欧拉函数
[bzoj2186]: [Sdoi2008]沙拉公主的困惑 考虑当 gcd(a,b)=1 则 gcd(nb+a,b)=1 所以[1,N!]与M!互质的个数就是 筛出[1,M]所有的素数p[i] 以及逆 ...
- CF567E President and Roads
\(\color{#0066ff}{ 题目描述 }\) 给出一个有向图,从起点走到终点(必须走最短路),问一条边是否一定会被经过,如果不经过它,可以减小它的多少边权使得经过它(边权不能减少到0) \( ...
- P2117 小Z的矩阵
题意: 给你一个初始01矩阵 三种操作 1.给一个x,把第x行01互换 2.给一个x,把第x列01互换 3.求$(\sum_{i=1}^n\sum_{j=1}^nf[i][j]*f[j][i])%2$ ...