私は次の表を持っています
id count hour age range
-------------------------------------
0 5 10 61 10-200
1 6 20 61 10-200
2 7 15 61 10-200
5 9 5 61 201-300
7 10 25 61 201-300
0 5 10 62 10-20
1 6 20 62 10-20
2 7 15 62 10-20
5 9 5 62 21-30
1 8 6 62 21-30
7 10 25 62 21-30
10 15 30 62 31-40
クエリに従って試した列範囲の個別の値を選択する必要があります
Select distinct range as interval from table name where age = 62;
その結果は次のように列に表示されます。
interval
----------
10-20
21-30
31-41
次のように結果を得るにはどうすればよいですか?
10-20, 21-30, 31-40
編集済み:私は今、次のクエリを試しています:
select sys_connect_by_path(range,',') interval
from
(select distinct NVL(range,'0') range , ROW_NUMBER() OVER (ORDER BY RANGE) rn
from table_name where age = 62)
where connect_by_isleaf = 1 CONNECT BY rn = PRIOR rn+1 start with rn = 1;
次のような出力が得られます。
Interval
----------------------------------------------------------------------------
, 10-20,10-20,10-20,21-30,21-30, 31-40
みんな私が望む出力を得るのを手伝ってください。