File tree 1 file changed +28
-0
lines changed
1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change
1
+ /********************
2
+ // 197. Rising Temperature
3
+ // Given a Weather table, write a SQL query to find all dates' Ids with higher temperature compared to its previous (yesterday's) dates.
4
+
5
+ +---------+------------------+------------------+
6
+ | Id(INT) | RecordDate(DATE) | Temperature(INT) |
7
+ +---------+------------------+------------------+
8
+ | 1 | 2015-01-01 | 10 |
9
+ | 2 | 2015-01-02 | 25 |
10
+ | 3 | 2015-01-03 | 20 |
11
+ | 4 | 2015-01-04 | 30 |
12
+ +---------+------------------+------------------+
13
+ For example, return the following Ids for the above Weather table:
14
+ +----+
15
+ | Id |
16
+ +----+
17
+ | 2 |
18
+ | 4 |
19
+ +----+
20
+ ********************/
21
+
22
+ # Write your MySQL query statement below
23
+ SELECT w2.Id
24
+ FROM Weather AS w1
25
+ INNER JOIN Weather AS w2
26
+ ON w1.Temperature < w2.Temperature
27
+ AND DATEDIFF(w2.RecordDate, w1.RecordDate) = 1
28
+
You can’t perform that action at this time.
0 commit comments