回答編集履歴
1
追記
test
CHANGED
@@ -51,3 +51,23 @@
|
|
51
51
|
group by ID
|
52
52
|
|
53
53
|
```
|
54
|
+
|
55
|
+
※結局havingだけでやる方がよさそうですが、上記サブクエリを効率化するとこう
|
56
|
+
|
57
|
+
``` SQL
|
58
|
+
|
59
|
+
select ID,max(d) from tbl as t1
|
60
|
+
|
61
|
+
where not exists(
|
62
|
+
|
63
|
+
select 1 from tbl as t2
|
64
|
+
|
65
|
+
where d>'2017-12-31'
|
66
|
+
|
67
|
+
and t1.ID=t2.ID
|
68
|
+
|
69
|
+
)
|
70
|
+
|
71
|
+
group by ID
|
72
|
+
|
73
|
+
```
|