Try!
SQL> select * from table1;
CODE STR
----- ---------------------------------------------------------------
code1 2451020 2451130 2541420 2541220 2541230 2541241 2541231 2541230
code2 2451020 2451120 2541425 2541220 2541225 2541260 2541238 2541230
SQL>
SQL> select code,
2 str,
3 flag "level(结尾尾数)",
4 count(*) "countNum"
5 from
6 (select a.rn,
7 b.code,
8 b.str,
9 substr(substr(' ' || str || ' ',
10 instr(' ' || str || ' ', ' ', 1, a.rn) + 1,
11 instr(' ' || str || ' ', ' ', 1, a.rn + 1) - instr(' ' || str || ' ', ' ', 1, a.rn) - 1),
12 -2) flag
13 from (select level rn from (select max(length(str) - length(replace(str, ' ', ''))) diff from table1) connect by level <= diff + 1) a,
14 table1 b
15 where length(b.str) - length(replace(b.str, ' ', '')) + 1 >= a.rn)
16 group by code, str, flag
17 order by code, str, flag
18 /
CODE STR level(结尾尾数) countNum
----- --------------------------------------------------------------- --------------- ----------
code1 2451020 2451130 2541420 2541220 2541230 2541241 2541231 2541230 20 3
code1 2451020 2451130 2541420 2541220 2541230 2541241 2541231 2541230 30 3
code1 2451020 2451130 2541420 2541220 2541230 2541241 2541231 2541230 31 1
code1 2451020 2451130 2541420 2541220 2541230 2541241 2541231 2541230 41 1
code2 2451020 2451120 2541425 2541220 2541225 2541260 2541238 2541230 20 3
code2 2451020 2451120 2541425 2541220 2541225 2541260 2541238 2541230 25 2
code2 2451020 2451120 2541425 2541220 2541225 2541260 2541238 2541230 30 1
code2 2451020 2451120 2541425 2541220 2541225 2541260 2541238 2541230 38 1
code2 2451020 2451120 2541425 2541220 2541225 2541260 2541238 2541230 60 1
9 rows selected