LeetCode MySQL 197. 上升的温度
生活随笔
收集整理的這篇文章主要介紹了
LeetCode MySQL 197. 上升的温度
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
文章目錄
- 1. 題目
- 2. 解題
1. 題目
給定一個(gè) Weather 表,編寫(xiě)一個(gè) SQL 查詢(xún),來(lái)查找與之前(昨天的)日期相比溫度更高的所有日期的 Id。
+---------+------------------+------------------+ | Id(INT) | RecordDate(DATE) | Temperature(INT) | +---------+------------------+------------------+ | 1 | 2015-01-01 | 10 | | 2 | 2015-01-02 | 25 | | 3 | 2015-01-03 | 20 | | 4 | 2015-01-04 | 30 | +---------+------------------+------------------+ 例如,根據(jù)上述給定的 Weather 表格,返回如下 Id:+----+ | Id | +----+ | 2 | | 4 | +----+來(lái)源:力扣(LeetCode) 鏈接:https://leetcode-cn.com/problems/rising-temperature
著作權(quán)歸領(lǐng)扣網(wǎng)絡(luò)所有。商業(yè)轉(zhuǎn)載請(qǐng)聯(lián)系官方授權(quán),非商業(yè)轉(zhuǎn)載請(qǐng)注明出處。
2. 解題
# Write your MySQL query statement below select w1.Id from Weather w1, Weather w2 where date_sub(w1.RecordDate, interval 1 day) = w2.RecordDateand w1.Temperature > w2.Temperatureor
# Write your MySQL query statement below select w1.Id from Weather w1, Weather w2 where datediff(w1.RecordDate, w2.RecordDate) = 1and w1.Temperature > w2.Temperatureor
# Write your MySQL query statement below select w1.Id from Weather w1, Weather w2 where date_add(w2.RecordDate, interval 1 day) = w1.RecordDateand w1.Temperature > w2.Temperature我的CSDN博客地址 https://michael.blog.csdn.net/
長(zhǎng)按或掃碼關(guān)注我的公眾號(hào)(Michael阿明),一起加油、一起學(xué)習(xí)進(jìn)步!
總結(jié)
以上是生活随笔為你收集整理的LeetCode MySQL 197. 上升的温度的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: LeetCode 583. 两个字符串的
- 下一篇: LeetCode MySQL 184.