回答編集履歴
1
追記
answer
CHANGED
@@ -7,4 +7,17 @@
|
|
7
7
|
select * from Mxx
|
8
8
|
where date=[特定の時間]
|
9
9
|
```
|
10
|
-
※SQLiteがlead()やlag()に対応していれば、もっと簡潔になりそうですけどね。
|
10
|
+
※SQLiteがlead()やlag()に対応していれば、もっと簡潔になりそうですけどね。
|
11
|
+
|
12
|
+
もし、特定の日時のデータが存在するかどうか不明な時は、そのデータが存在するかどうかも条件に加えます。
|
13
|
+
※簡潔にするためwithを使用
|
14
|
+
```SQL
|
15
|
+
with target as (
|
16
|
+
select * from Mxx where date=[特定の時間]
|
17
|
+
)
|
18
|
+
select * from Mxx
|
19
|
+
where date=(select max(date) from Mxx where date<[特定の時間])
|
20
|
+
and exists(select 1 from target)
|
21
|
+
union all
|
22
|
+
select * from target
|
23
|
+
```
|