回答編集履歴
1
追記
test
CHANGED
@@ -17,3 +17,29 @@
|
|
17
17
|
```
|
18
18
|
|
19
19
|
※SQLiteがlead()やlag()に対応していれば、もっと簡潔になりそうですけどね。
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
もし、特定の日時のデータが存在するかどうか不明な時は、そのデータが存在するかどうかも条件に加えます。
|
24
|
+
|
25
|
+
※簡潔にするためwithを使用
|
26
|
+
|
27
|
+
```SQL
|
28
|
+
|
29
|
+
with target as (
|
30
|
+
|
31
|
+
select * from Mxx where date=[特定の時間]
|
32
|
+
|
33
|
+
)
|
34
|
+
|
35
|
+
select * from Mxx
|
36
|
+
|
37
|
+
where date=(select max(date) from Mxx where date<[特定の時間])
|
38
|
+
|
39
|
+
and exists(select 1 from target)
|
40
|
+
|
41
|
+
union all
|
42
|
+
|
43
|
+
select * from target
|
44
|
+
|
45
|
+
```
|