回答編集履歴
1
追記
answer
CHANGED
@@ -24,4 +24,14 @@
|
|
24
24
|
and t1.ID=t2.ID
|
25
25
|
)
|
26
26
|
group by ID
|
27
|
+
```
|
28
|
+
※結局havingだけでやる方がよさそうですが、上記サブクエリを効率化するとこう
|
29
|
+
``` SQL
|
30
|
+
select ID,max(d) from tbl as t1
|
31
|
+
where not exists(
|
32
|
+
select 1 from tbl as t2
|
33
|
+
where d>'2017-12-31'
|
34
|
+
and t1.ID=t2.ID
|
35
|
+
)
|
36
|
+
group by ID
|
27
37
|
```
|