[LeetCode]-DataBase-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 |
+----+ 需求:查询今天气温比前一天的高的日期
CREATE TABLE Weather(
Id TINYINT UNSIGNED,
Date date,
Temperature TINYINT
)ENGINE=MyISAM CHARSET=utf8;
SELECT t1.Id
FROM Weather t1
WHERE t1.Temperature>(SELECT t2.Temperature
FROM Weather t2
WHERE t2.Date=ADDDATE(t1.Date,INTERVAL -1 DAY))
[LeetCode]-DataBase-Rising Temperature的更多相关文章
- 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 的日期是 ...
- Leetcode 197. Rising Temperature
Given a Weather table, write a SQL query to find all dates' Ids with higher temperature compared to ...
- leetcode database题目
LeetCode有10道SQL的题目,最近学习SQL语言,顺便刷题强化一下, 说实话刷完SQL学习指南这本书,不是很难,上面的例子 跟语法规则我都能理解透, 实际中来做一些比较难的业务逻辑题,却一下子 ...
- [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 ...
- [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 ...
- leetcode - database - 177. Nth Highest Salary (Oracle)
题目链接:https://leetcode.com/problems/nth-highest-salary/description/ 题意:查询出表中工资第N高的值 思路: 1.先按照工资从高到低排序 ...
- 197. Rising Temperature
Given a Weather table, write a SQL query to find all dates' Ids with higher temperature compared to ...
随机推荐
- Python中的四种数据结构
Python中的内置数据结构(Built-in Data Structure):列表list.元组tuple.字典dict.集合set,涵盖的仅有部分重点. 目录: 一.列表list 二.元组tup ...
- 利用aopc创建schema失败
执行neo4j-graph-algorithms的例子,运行以下代码报错: CALL apoc.schema.assert( {Category:['name']}, {Business:['id'] ...
- npm学习(六)之如何创建 Node.js 模块
如何创建 Node.js 模块 Node.js 模块是一种可以发布到 npm 的包.当你创建一个新模块时,创建 package.json 文件是第一步. 你可以使用 npm init 命令创建 pac ...
- CF528E Triangles 3000
cf luogu 既然要求三角形面积,不如考虑三角形的面积公式.因为是三条直线,所以可以考虑利用三个交点来算面积,如果这个三角形按照逆时针方向有\(ABC\)三点,那么他的面积为\(\frac{\ve ...
- oracle常用函数(2)
1) trunc函数,用于截断数字, 截断数字,用法为:trunc(n1,n2),n1表示要被截断的数字,n2表示要截断到那位,但是不会进行四舍五入. n2还可以表示负数,表示截断到小数点前,意思就是 ...
- Nginx进行UDP的负载均衡
准备工作: 服务器1:192.168.33.102 搭建nginx服务,作为反向代理的中转站 服务器2:192.168.33.103 nginx要反向代理的服务器 一.在服务器1上搭建n ...
- 脚本_通过进程与端口判断myslq服务
#!bin/bashif [[ $port -eq 1 || $porcess -eq 2 ]];then #通过条件判断端口和进程执行的返回值. echo "mysql is s ...
- 单调队列优化DP || [Poi2014]Little Bird || BZOJ 3831 || Luogu P3572
题面:[POI2014]PTA-Little Bird 题解: N<=1e6 Q<=25F[i]表示到达第i棵树时需要消耗的最小体力值F[i]=min(F[i],F[j]+(D[j]> ...
- QByteArray与QString的互相转换
QByteArray baData; QString str = QString(baData); // 反过来转换: QByteArray by1 = str.toLatin1(); QByteAr ...
- 【10】Python urllib、编码解码、requests、多线程、多进程、unittest初探、__file__、jsonpath
1 urllib urllib是一个标准模块,直接import就可以使用 1.1get请求 from urllib.request import urlopen url='http://www.nnz ...