[LeetCode][SQL]Rising Temperature

https://leetcode.com/problems/rising-temperature/

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 |
+----+


之前交了几次都没加TO_DAYS函数,我错了,我不该懒得装MySQL。

select A.Id from Weather A where A.Temperature > (select B.Temperature from Weather B where TO_DAYS(A.Date) - 1 = TO_DAYS(B.Date))
时间: 2024-07-30 18:36:59

[LeetCode][SQL]Rising Temperature的相关文章

LeetCode:Rising Temperature - 上浮的温度

1.题目名称 Rising Temperature(上浮的温度) 2.题目地址 https://leetcode.com/problems/rising-temperature 3.题目内容 给出一组每日的气温数据,返回当日气温高于昨日气温的日期. 例如,Weather表中的数据如下: +---------+------------+------------------+ | Id(INT) | Date(DATE) | Temperature(INT) | +---------+-------

【Leetcode】Rising Temperature

题目链接:https://leetcode.com/problems/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(IN

leetcode: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) | +---------+------------+----

Leetcode 197. 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) | +---------+------------+----

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

题目标签: 题目给了我们一个 温度表格,让我们找到 所有温度比之前一天高的,返回id. 建立 Weather w1, Weather w2,找到当w1 的温度 大于 w2 的时候,而且 w1 的日期是在w2 的后一天,返回id. Java Solution: Runtime:  338 ms, faster than 66 % Memory Usage: N/A 完成日期:06/01/2019 关键点:利用TO_DAYS 来比较日期. # Write your MySQL query state

LeetCode SQL题目(第一弹)

LeetCode SQL题目 注意:Leetcode上的SQL编程题都提供了数据表的架构程序,只需要将它贴入本地数据库即可调试自己编写的程序 不管是MS-SQL Server还是MySQL都需要登陆才能使用,我没有使用SSMS 或Workbench,而是直接使用sqlcmd,解决登陆问题可以参考这个链接(http://www.cnblogs.com/skynothing/archive/2010/08/26/1809125.html)感谢这位博主的帮助. 181. Employees Earni

leetcode数据库sql之Rising Temperature

leetcode原文引用: 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) | +---------+---

[LeetCode] 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) | +---------+------------+----

LeetCode - Rising Temperature

Description:Given a Weather table, write a SQL query to find all dates' Ids with higher temperature compared to its previous (yesterday's) dates. 选出比前一天温度高的Id 使用自连接,to_days函数是返回从零年开始的总天数. (为何把=误写成<会Runtime Error啊 不应该是WrongAnser!) # Write your MySQL q