回答編集履歴
1
サブクエリを使わないパターン
test
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
|
11
11
|
from t
|
12
12
|
|
13
|
-
where
|
13
|
+
where
|
14
14
|
|
15
15
|
ID = (
|
16
16
|
|
@@ -29,3 +29,43 @@
|
|
29
29
|
|
30
30
|
|
31
31
|
[http://sqlfiddle.com/#!6/cce11e/7](http://sqlfiddle.com/#!6/cce11e/7)
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
---
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
列がその3つだけならこんなかんじでもできるかも。
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
```sql
|
44
|
+
|
45
|
+
select
|
46
|
+
|
47
|
+
min(t.id) as ID, t."GROUP", t.PARAM
|
48
|
+
|
49
|
+
from t inner join t as x
|
50
|
+
|
51
|
+
on x."GROUP" = t."GROUP"
|
52
|
+
|
53
|
+
group by
|
54
|
+
|
55
|
+
t."GROUP", t.PARAM
|
56
|
+
|
57
|
+
having
|
58
|
+
|
59
|
+
t.PARAM = max(x.PARAM)
|
60
|
+
|
61
|
+
order by
|
62
|
+
|
63
|
+
ID asc
|
64
|
+
|
65
|
+
```
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
[http://sqlfiddle.com/#!6/cce11e/9](http://sqlfiddle.com/#!6/cce11e/9)
|
70
|
+
|
71
|
+
|