我有一张像这样的大桌子:
DATA NUM CITY
----------------------------------- --------------- --------------------
ABC140180B 51368 Hong Kong
ABC140180 98563 New York
CENTER ABC140180 65125 Philadephia
ABC230142 48101 PARK
SOUTHFIELD ABC230142 48083 Tokyo
GENERAL SURGERY ABC230053LJ 45896 Philadephia
CARDIOVASCULAR MEDICINE ABC230053LK 48192 Philadephia
GYNECOLOGIC ABC230053LL 25874 Philadephia
NEUROSURGERY ABC230053LC 48192 Tokyo
HENRY ABC230053FG 11524 Tokyo
UROGYNECOLOGY ABC230053FH 62531 Tokyo
有什么方法可以用#34; ABCXXXXXXX"来抓取所有字符串。从数据创建一个新表,其中一个新列包含如下数据:
DATA NUM CITY DSH
----------------------------------- --------------- -------------------- -----------------
ABC140180B 51368 Hong Kong ABC140180B
ABC140180 98563 New York ABC140180
CENTER ABC140180 65125 Philadephia ABC140180
ABC230142 48101 PARK ABC230142
SOUTHFIELD ABC230142 48083 Tokyo ABC230142
GENERAL SURGERY ABC230053LJ 45896 Philadephia ABC230053LJ
CARDIOVASCULAR MEDICINE ABC230053LK 48192 Philadephia ABC230053LK
GYNECOLOGIC ABC230053LL 25874 Philadephia ABC230053LL
NEUROSURGERY ABC230053LC 48192 Tokyo ABC230053LC
HENRY ABC230053FG 11524 Tokyo ABC230053FG
UROGYNECOLOGY ABC230053FH 62531 Tokyo ABC230053FH
任何人都可以帮助我
提前致谢
答案 0 :(得分:1)
根据您提供的示例,您需要最后一个"令牌"在最后一个空格之后的字符串中。
Oracle提供regexp_substr()
:
select . . ., regexp_substr(' ' || data, ' [^ ]*$', 1, 1) as dsh
答案 1 :(得分:1)
也可以使用substr()
和instr()
:
select t.*,
substr(t.YourColumn, instr(t.YourColumn, 'ABC') + 1) as DSH
from YourTable t;
这将从ABC
和前进