oracle中 sql截取某个字符前面和后面的值

--创建测试表及数据
create table test
(name varchar2(10));
 
insert into test values ('2-15');
insert into test values ('2-33');
insert into test values ('2-3');
insert into test values ('12-8');
insert into test values ('12-22');
insert into test values ('12-3');
 --执行
select name,substr(name,1,instr(name,'-')-1) 前,
	substr(name,instr(name,'-')+1,length(name)-instr(name,'-')) 后 
from test
--结果
NAME  前  后
2-15  2   15
2-33  2   33
2-3   2    3
...

你可能感兴趣的:(DateSource)