File tree Expand file tree Collapse file tree 1 file changed +0
-19
lines changed Expand file tree Collapse file tree 1 file changed +0
-19
lines changed Original file line number Diff line number Diff line change 1
- -- Given a Weather table, write a SQL query to find all dates' Ids with higher temperature compared to its previous (yesterday's) dates.
2
- --
3
- -- +---------+------------+------------------+
4
- -- | Id(INT) | Date(DATE) | Temperature(INT) |
5
- -- +---------+------------+------------------+
6
- -- | 1 | 2015-01-01 | 10 |
7
- -- | 2 | 2015-01-02 | 25 |
8
- -- | 3 | 2015-01-03 | 20 |
9
- -- | 4 | 2015-01-04 | 30 |
10
- -- +---------+------------+------------------+
11
- -- For example, return the following Ids for the above Weather table:
12
- -- +----+
13
- -- | Id |
14
- -- +----+
15
- -- | 2 |
16
- -- | 4 |
17
- -- +----+
18
-
19
-
20
1
select w1 .Id from Weather w1, Weather w2 where w1 .Temperature > w2 .Temperature and to_days(w1 .Date ) - to_days(w2 .date ) = 1 ;
You can’t perform that action at this time.
0 commit comments