1

たとえば、2つの文字列があります。

  • 'ソース:シーベル; 名前:メリー・ジェーン。性別:F; 年齢:24歳。N;'
  • 'ソース:シーベル; 名前:マリー; 性別:F; 年齢:24歳。N;'

私が必要とする結果は次のとおりです。

  • 名前:メリー・ジェーン。
  • 名前:マリー;

ほとんどの場合、以下のコードを逆にする必要があります

with cte1 as  (
    select 1 id, 'Source:Siebel; Name:Mary Jane; Gender:F; Age:24; N;' str from dual
    union all
    select 2 id, 'Source:Siebel; Name:Marie; Gender:F; Age:24; N;' str from dual
), cte2 as (
    SELECT distinct id, trim(regexp_substr(str, '[^ ]+', 1, level)) str
    FROM cte1 t
    CONNECT BY instr(str, ' ', 1, level - 1) > 0
)
select distinct t1.str
from cte2 t1
join cte2 t2 on (t1.str = t2.str and t1.id != t2.id)

文字列間の類似性を返すOracle関数から

結果として、2 つの文字列の類似性 [QueryResult] が得られました。

ここに画像の説明を入力

このSQLスクリプトをOracle Fusionで実行する必要があるため、この手順を使用できません

4

2 に答える 2

0

これは役に立ちますか?

SQL> with cte1 as  (
  2   select 1 id, 'Source:Siebel; Name:Mary Jane; Gender:F; Age:24; N;' str from dual
  3   union all
  4   select 2 id, 'Source:Siebel; Name:Marie; Gender:F; Age:24; N;' str from dual
  5   ),
  6  cte2 as
  7    (select id,
  8       column_value lvl,
  9       trim(regexp_substr(str, '[^;]+', 1, column_value)) str
 10     from cte1 cross join
 11       table(cast(multiset(select level from dual
 12                           connect by level <= regexp_count(str, ';') +1
 13                          ) as sys.odcinumberlist))
 14    )
 15  select a.str, b.str
 16  From cte2 a join cte2 b on a.id < b.id and a.lvl = b.lvl and a.str <> b.str;

STR             STR
--------------- ---------------
Name:Mary Jane  Name:Marie

SQL>
于 2020-04-10T12:45:43.050 に答える