zoukankan      html  css  js  c++  java
  • 197. 上升的温度

    表 Weather

    +---------------+---------+
    | Column Name | Type |
    +---------------+---------+
    | id | int |
    | recordDate | date |
    | temperature | int |
    +---------------+---------+
    id 是这个表的主键
    该表包含特定日期的温度信息
     

    编写一个 SQL 查询,来查找与之前(昨天的)日期相比温度更高的所有日期的 id 。

    返回结果 不要求顺序 。

    查询结果格式如下例:

    Weather
    +----+------------+-------------+
    | id | recordDate | Temperature |
    +----+------------+-------------+
    | 1 | 2015-01-01 | 10 |
    | 2 | 2015-01-02 | 25 |
    | 3 | 2015-01-03 | 20 |
    | 4 | 2015-01-04 | 30 |
    +----+------------+-------------+

    Result table:
    +----+
    | id |
    +----+
    | 2 |
    | 4 |
    +----+
    2015-01-02 的温度比前一天高(10 -> 25)
    2015-01-04 的温度比前一天高(30 -> 20)

    来源:力扣(LeetCode)
    链接:https://leetcode-cn.com/problems/rising-temperature
    著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。

    # Write your MySQL query statement below
    select a.Id
    from Weather as a,Weather as b
    where a.Temperature > b.Temperature and dateDiff(a.RecordDate,b.RecordDate)=1
  • 相关阅读:
    MySql 数据类型
    MySql 数据库的增删改
    MySql 联合查询
    Mysql 库的管理 --->>>>DDL
    MySql 子查询
    MySql 分页查询
    sql99语法的连接查询
    MySql 连接查询
    MySql 分组函数
    jQ处理页面中尺寸过大的图片
  • 原文地址:https://www.cnblogs.com/xxxsans/p/13886614.html
Copyright © 2011-2022 走看看