SELECT SUBSTR(REGEXP_SUBSTR('CCCCXXXCCCCCCCCCCCCCCCCXXCCCCCCCCCCCCCCCCCCCCCCC', '^(.)\1*.'), -2, 2) RESULT
FROM DUAL;
Ini mengembalikan CX
Ini solusi lain:
Select Replace (Wm_Concat (C), ',', '')
From
(Select Substr ('CCCXCCCXXXCCCCCCCCCCCCCCCCXXCCCCCCCCCCCCCCCC', Rownum, 1) C,
Min (Rownum) Rn
From Dual
Connect By Rownum <= Length ( 'CCCXCCCXXXCCCCCCCCCCCCCCCCXXCCCCCCCCCCCCCCCC')
Group By Substr ( 'CCCXCCCXXXCCCCCCCCCCCCCCCCXXCCCCCCCCCCCCCCCC', Rownum, 1)
Order By Rn
) X;
Ini mengembalikan semua karakter unik dalam urutan kemunculannya. Btw, ya, kelihatannya mengerikan