回答編集履歴
3
推敲
test
CHANGED
@@ -10,17 +10,17 @@
|
|
10
10
|
|
11
11
|
), unit as (
|
12
12
|
|
13
|
-
select max(rank) /4 as rank_unit from base
|
13
|
+
select trunc((max(rank) /4) + 0.9) as rank_unit from base
|
14
14
|
|
15
15
|
)
|
16
16
|
|
17
|
-
select rank / rank_unit as RANK_GROUP
|
17
|
+
select trunc(rank / rank_unit) as RANK_GROUP
|
18
18
|
|
19
19
|
, AVG(SCORE), AVG(AGE)
|
20
20
|
|
21
21
|
FROM base , unit
|
22
22
|
|
23
|
-
GROUP BY rank / rank_unit
|
23
|
+
GROUP BY trunc(rank / rank_unit)
|
24
24
|
|
25
25
|
```
|
26
26
|
|
2
推敲
test
CHANGED
@@ -8,19 +8,19 @@
|
|
8
8
|
|
9
9
|
from SCORE_TBL
|
10
10
|
|
11
|
-
),
|
11
|
+
), unit as (
|
12
12
|
|
13
|
-
select max(rank) as
|
13
|
+
select max(rank) /4 as rank_unit from base
|
14
14
|
|
15
15
|
)
|
16
16
|
|
17
|
-
select rank /
|
17
|
+
select rank / rank_unit as RANK_GROUP
|
18
18
|
|
19
19
|
, AVG(SCORE), AVG(AGE)
|
20
20
|
|
21
|
-
FROM base ,
|
21
|
+
FROM base , unit
|
22
22
|
|
23
|
-
GROUP BY rank /
|
23
|
+
GROUP BY rank / rank_unit
|
24
24
|
|
25
25
|
```
|
26
26
|
|
1
追記
test
CHANGED
@@ -23,3 +23,5 @@
|
|
23
23
|
GROUP BY rank / (max_rank / 4)
|
24
24
|
|
25
25
|
```
|
26
|
+
|
27
|
+
件数が多いなら一時テーブル経由にした方が高速かもしれませんね。
|