Target:
Cut the "2000-3000" string into consecutive strings in Oracle, which are "2000" and "3000" respectively.
analyze:
There is no split in oracle. This is a function, and we don't want to customize a function. But use the instr() function to locate the position of the character in the string, and then combine the substr() function to achieve our needs.
solution:
SQL:
select instr('3000-4000','-',1,1) from dual;
Explanation: 1. ' 3000-4000 ' => is our source string
2. '-'=> is the sign of separation
3. The first 1 starts from the left, if it is -1, it starts from the right.
4. The second 1 is the number of times "-" appears.
SQL: shorthand
select instr('3000-4000','-') from dual;
Final SQL:
select SUBSTR('2000-3000', (select instr('2000-3000','-') from dual)+1,length('2000-3000') ) minValue from dual;
select SUBSTR('2000-3000', (select instr('2000-3000','-') from dual)+1,length('2000-3000') ) maxValue from dual;
select SUBSTR('2000-3000', (select instr('2000-3000','-') from dual)+1,length('2000-3000') ) maxValue from dual;