2017-11-18 119 views
1

我在Oracle 11g数据库中有一个表,名为REPORT的列。我正在尝试编写一个select语句来显示下面的所需结果。我需要选择“\”和后面出现的“#”之间的字符串。我认为这可以使用regexp_substr函数完成,但我没有取得任何成功。我有太多的例子说明我上周在这里发布的失败尝试。任何帮助,将不胜感激。用于选择''和'#'之间字符串的Oracle SQL语句

REPORT_COLUMN

#Med Reports\Client, Ray.dco# 
Financial Reports\Client, Justin-1.dco#Financial Reports/Client, Justin-1.dco# 
#Med Reports\Client, Jessy.dco# 
Financial Reports\Client, Channa-1.dco#Financial Reports/Client, Charnisha-1.dco# 

要求的结果:

Client, Ray.dco 
Client, Justin-1.dco 
Client, Jessy.dco 
Client, Channa-1.dco 

回答

0
select regexp_substr(REPORT_COLUMN,'\\(.*?)#',1,1,'',1) 
    from Table 
+0

谢谢。这是完美的。我承认我还没有完全理解它。我想我需要研究regexp_substr。 –