1. 程式人生 > >leetcode197-Rising Temperature

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

找出溫度比昨天高的那一天對應的ID。

問題求解:

1、where

select w1.Id from Weather w1, Weather w2 
where TO_DAYS(w1.Date)=TO_DAYS(w2.Date)+1 and w1.Temperature>w2.Temperature;

2、inner join … on

select w1.Id from
Weather w1 inner join Weather w2 on TO_DAYS(w1.Date)=TO_DAYS(w2.Date)+1 and w1.Temperature>w2.Temperature;

相關推薦

leetcode197-Rising Temperature

問題描述: Given a Weather table, write a SQL query to find all dates’ Ids with higher temperature compared to its previous (yesterday’

197. Rising Temperature--solution

sql sin tab ret val nbsp code date_add interval Question: Given a Weather table, write a SQL query to find all dates‘ Ids with higher t

LeetCode Rising Temperature

Problem Given a Weather table, write a SQL query to find all dates’ Ids with higher temperature compared to its previous (

LeetCode | Database| Rising Temperature

題目描述: 給出下面一個weather表,寫mysql查詢找出所有相比於前一天溫度高的ID 可以得出下圖結果: 題目解答: 分析: 在這裡,需運用DATEDIFF() 函式返回兩個日期之間的天數: DATEDIFF(date1,date2

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

Rising Temperature:查詢比前一天氣溫高的天氣ID

Given a Weather table, write a SQL query to find all dates' Ids with higher temperature compared to its previous (yesterday's) dates.

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

197. Rising Temperature(必看)

Datediff 用法SELECTDATEDIFF('2011-08-08','2011-08-17');-- "-9 days"SELECTDATEDIFF('2011-08-17','2011-08-08');--  "9 days"Given a Weather table, write a SQL q

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) date

【leetcode Database】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) dat

bzoj 2276: [Poi2011]Temperature——單調隊列

連續 none input per open 路徑 span inpu 位置 Description 某國進行了連續n天的溫度測量,測量存在誤差,測量結果是第i天溫度在[l_i,r_i]範圍內。 求最長的連續的一段,滿足該段內可能溫度不降 第一行n 下面n行,每行

BZOJ2276: [Poi2011]Temperature

std opened 最長 hid 區間 ges 技術 emp tin n<=1000000個數,每個數的選擇範圍在Li到Ri<=1000000000之間,求最長能得到多長的連續不下降序列。 首先可以暴力,f[i][j]表示前i個數,最後一個數取j,然後瞎轉移就

[BZOJ] 2276: [Poi2011]Temperature

clu pan rep access int com tun sub out 2276: [Poi2011]Temperature Time Limit: 20 Sec Memory Limit: 32 MBSubmit: 731 Solved: 334[Subm

778. Swim in Rising Water

blog example cat point each color () depth higher On an N x N grid, each square grid[i][j] represents the elevation at that point (i,j).

[LeetCode] Swim in Rising Water 在上升的水中遊泳

uri depth rain location dir least lse tput wim On an N x N grid, each square grid[i][j] represents the elevation at that point (i,j).

BZOJ2276 [Poi2011]Temperature 【單調隊列】

long long -- == getch emp CP fin div 空間 題目鏈接 BZOJ2276 題解 一開始看錯題,以為求的是可以不連續的,想出一個奇怪的線段樹,發現空間根本開不下?? 題目要我們求連續的最長可能不下降區間 對於區間\([l,r]\)如果合法,當

【POI2011】TEM-Temperature

題面 某國進行了連續n天的溫度測量,測量存在誤差,測量結果是第i天溫度在[li,ri]範圍內。 求最長的連續的一段,滿足該段內可能溫度不降。 分析 我們發現要滿足這個可能的溫度不降,必須避免Li>Rj(i<j)的情況出現。 因此,我們維護L的單調不遞減佇列,對於每個R,需要找到一個比它小

[Poi2011]Temperature

Description The Byteotian Institute of Meteorology (BIM) measures the air temperature daily. The measurement is done automatically, and its result immediat

[BZOJ2276][Poi2011]Temperature(單調佇列)

Address 洛谷P3522 BZOJ2276 LOJ#2164 Solution 先解決一個小問題:如何判斷一個連續子段是否合法。 很容易得出, a

Pro Industrial IoT testers occupy apartments in Berlin in outcry over rising rent prices

www.inhandnetworks.de In protest at scarce and unaffordable living space, activists occupied several empty apartments in Berlin on