表格中的特定列中,工作人员讲述了付款或收据的性质。
编写类似'PAYMENT OF SALARIES FOR THE MONTH OF NOVEMBER 2018'
之类的东西。我希望能够有一些代码(ORACLE SQL)从这些叙述中挑选几个月。
答案 0 :(得分:1)
您可以连续使用基于正则表达式的函数(_replace,_substr,_count)提取月份名称,前提是所有具有相同格式模型的数据都以“月份年份”组合结尾
with t(str) as
(
select 'PAYMENT OF SALARIES FOR THE MONTH OF NOVEMBER 2018' from dual
), t2 as
(
select rtrim(str,regexp_replace(str,'(\D)')) as str
from t
), t3 as
(
select regexp_substr(str,'[^ ]+',1,level) as str,
regexp_count(str,'[^ ]+') as cnt,
level as lvl
from t2
connect by level <= regexp_count(str,'[^ ]+')
)
select str
from t3
where lvl = cnt;
STR
--------
NOVEMBER
答案 1 :(得分:0)
即使您指定的文本格式相同,它也会起作用:
select * from (select rownum, regexp_substr("column1",'[^ ]+', 1, level) from Table1
connect by regexp_substr("column1", '[^ ]+', 1, level) is not null) where rownum<=8
minus
select * from (select rownum, regexp_substr("column1",'[^ ]+', 1, level) from Table1
connect by regexp_substr("column1", '[^ ]+', 1, level) is not null) where rownum<8;
答案 2 :(得分:0)
where
Date >= to_date(substr(:from_date ,1,10),'YYYY/MM/DD')
and
Date <= to_date(substr(:last_date,1,10),'YYYY/MM/DD')