Reputation: 223
I need a SQL query to get value after brackets..
For example, from the input
Kingdom of Saudi Arabia (KSA)
I need the output of KSA
.
Could anyone help me with this?
Upvotes: 0
Views: 461
Reputation: 142705
Or, using substr + instr
combination:
SQL> with test (col) as
2 (select 'Kingdom of Saudi Arabi ( KSA )' from dual)
3 select trim(substr(col,
4 instr(col, '(') + 1,
5 instr(col, ')') - instr(col, '(') - 1
6 )) result
7 from test;
RES
---
KSA
SQL>
Upvotes: 0
Reputation: 1269693
One method uses regexp_replace()
:
select regexp_replace('Kingdom of Saudi Arabi ( KSA )', '^.*[(](.*)[)].*$', '\1')
from dual;
Upvotes: 2