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的更多相关文章

  1. leetcode 197. Rising Temperature sql_Date用法

    https://leetcode.com/problems/rising-temperature/description/ 题目需要选出今天比昨天气温高的ID 用join,默认是inner join需 ...

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

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

  3. Leetcode 197. Rising Temperature

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

  4. leetcode database题目

    LeetCode有10道SQL的题目,最近学习SQL语言,顺便刷题强化一下, 说实话刷完SQL学习指南这本书,不是很难,上面的例子 跟语法规则我都能理解透, 实际中来做一些比较难的业务逻辑题,却一下子 ...

  5. [LeetCode] Rising Temperature 上升温度

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

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

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

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

  8. [SQL]197. Rising Temperature

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

  9. leetcode - database - 177. Nth Highest Salary (Oracle)

    题目链接:https://leetcode.com/problems/nth-highest-salary/description/ 题意:查询出表中工资第N高的值 思路: 1.先按照工资从高到低排序 ...

  10. 197. Rising Temperature

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

随机推荐

  1. 声明一个LIst类型的数组

    ArrayList[] graphArrayList = new ArrayList[4]; for(int i=0;i<graphArrayList.length;i++){ graphArr ...

  2. 高效编程之 concurrent.future

    背景 我们知道 Python 中有多线程threading 和多进程multiprocessing 实现并发, 但是这两个东西开销很大,一是开启线程/进程的开销,二是主程序和子程序之间的通信需要 序列 ...

  3. MySQL中的索引简介

    MySQL中的SQL的常见优化策略 MySQL中的索引优化 MySQL中的索引简介 一. 索引的优点 为什么要创建索引?这是因为,创建索引可以大大提高系统的查询性能. 第一.通过创建唯一性索引,可以保 ...

  4. Freemarker模板的使用简介

    需要的jar包: 在pom.xml文件中贴入 <dependency> <groupId>junit</groupId> <artifactId>jun ...

  5. 一分钟理解sku和spu

    SPU SPU = Standard Product Unit (标准化产品单位) SPU是商品信息聚合的最小单位,是一组可复用.易检索的标准化信息的集合,该集合描述了一个产品的特性.通俗点讲,属性值 ...

  6. iOS常用的数学函数

    1. 三角函数    double sin (double);正弦    double cos (double);余弦    double tan (double);正切    2 .反三角函数    ...

  7. iconv_close - 关闭字符转换描述符

    总览 (SYNOPSIS) #include <iconv.h> int iconv_close (iconv_t cd); 描述 (DESCRIPTION) iconv_close 函数 ...

  8. hive模拟数据

    人员表 id,姓名,爱好,住址 1,小明1,lol-book-movie,beijing:mashibing-shanghai:pudong 2,小明2,lol-book-movie,beijing: ...

  9. 数据可视化之颜色,线型,maker

    https://blog.csdn.net/m0_37362454/article/details/82791527 https://blog.csdn.net/qiu931110/article/d ...

  10. css画心形、三角形的总结

    .heart { width: 10px; height: 10px; /* position: fixed; */ background: #fff; transform: rotate(45deg ...