表の列:interval varchar(12)
ユーザーがこの列に次のようにデータを入力すると:
1
10-20
3-5
5-3
25-34
20-25
2
4-8
出力は次のようになります。
1
2
3-5
4-8
9-10
10-20
20-25
25-34
SELECT col
FROM
(
SELECT '1' col FROM DUAL UNION ALL
SELECT '10-20' FROM DUAL UNION ALL
SELECT '3-5' FROM DUAL UNION ALL
SELECT '5-3' FROM DUAL UNION ALL
SELECT '25-34' FROM DUAL UNION ALL
SELECT '20-25' FROM DUAL UNION ALL
SELECT '2' FROM DUAL UNION ALL
SELECT '4-8' FROM DUAL
)
ORDER BY
TO_NUMBER(regexp_substr(col, '\w+', 1, 1))
, TO_NUMBER(regexp_substr(col, '\w+', 1, 2))
1
2
3-5
4-8
5-3
10-20
20-25
25-34