回答編集履歴
2
かいぎょう
test
CHANGED
@@ -66,7 +66,11 @@
|
|
66
66
|
|
67
67
|
select id,category from tbl as t1
|
68
68
|
|
69
|
+
where not exists(
|
70
|
+
|
71
|
+
select 1 from tbl
|
72
|
+
|
69
|
-
where
|
73
|
+
where category=t1.category and d>t1.d having count(*)>=3)
|
70
74
|
|
71
75
|
) as sub)
|
72
76
|
|
1
ちょうせい
test
CHANGED
@@ -56,23 +56,19 @@
|
|
56
56
|
|
57
57
|
|
58
58
|
|
59
|
-
これ以外のデータを削除するので、
|
59
|
+
これ以外のデータを削除するので、サブクエリにいれてnotで引っ掛ける
|
60
60
|
|
61
61
|
```SQL
|
62
62
|
|
63
63
|
delete from tbl
|
64
64
|
|
65
|
-
where (id,category) in (select * from(
|
65
|
+
where not (id,category) in (select * from(
|
66
66
|
|
67
67
|
select id,category from tbl as t1
|
68
68
|
|
69
|
-
where not exists(
|
69
|
+
where not exists(select 1 from tbl where category=t1.category and d>t1.d having count(*)>=3)
|
70
70
|
|
71
|
-
select 1 from tbl
|
72
|
-
|
73
|
-
where category=t1.category and d>t1.d having count(*)<3)
|
74
|
-
|
75
|
-
) as sub)
|
71
|
+
) as sub)
|
76
72
|
|
77
73
|
```
|
78
74
|
|