File tree Expand file tree Collapse file tree 1 file changed +50
-1
lines changed Expand file tree Collapse file tree 1 file changed +50
-1
lines changed Original file line number Diff line number Diff line change 21
21
-- Solution
22
22
select a .Id
23
23
from weather a, weather b
24
- where a .Temperature > b .Temperature and datediff(a .recorddate ,b .recorddate )= 1
24
+ where a .Temperature > b .Temperature and datediff(a .recorddate ,b .recorddate )= 1
25
+
26
+
27
+
28
+ My sol:
29
+
30
+ 1 .
31
+ with cte as (
32
+ select
33
+ id as id1,
34
+ recordDate as rd1,
35
+ temperature as t1,
36
+ rd0 = lag(recordDate) over(order by id),
37
+ t0 = lag(temperature) over(order by id)
38
+ from Weather_12
39
+ )
40
+ select id1
41
+ from cte
42
+ where datediff(day, rd0, rd1) = 1 and t1 > t0
43
+
44
+ 2 .
45
+ select a .id
46
+ from Weather_12 a inner join Weather_12 b on a .temperature > b .temperature
47
+ and datediff(day, b .recorddate , a .recorddate ) = 1
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
You can’t perform that action at this time.
0 commit comments