sql怎么查询一列数据的相似度

 我来答
9iTreeNewBee
2014-10-28 · TA获得超过505个赞
知道小有建树答主
回答量:1800
采纳率:55%
帮助的人:425万
展开全部
SQL> create table ttb(name varchar2(10));

Table created.

SQL> insert into ttb values('asdfjkl');

1 row created.

SQL> insert into ttb values('asdkb');

1 row created.

SQL> insert into ttb values('asd323s');

1 row created.

SQL> commit;

Commit complete.

SQL> select * from ttb;

NAME
------------------------------
asdfjkl
asdkb
asd323s

SQL> select wm_concat(name) from ttb;

WM_CONCAT(NAME)
--------------------------------------------------------------------------------
asdfjkl,asdkb,asd323s

SQL> with t as (select to_char(wm_concat(name)) a from ttb) select substr(y.a,1,x.lvl-1) returnvalue from (select distinct(lvl) lvl from (select rn,first_value(lvl) over(order by lvl) lvl,cnt from (select rn,lvl,count(distinct(str)) cnt from (select rn,level lvl,substr(str,1,level) as str from (select rn,str from (select rn,regexp_substr(a,'[^,]+',1,level,'i') as str from (select rownum rn,a from t) connect by level<=length(a)-length(regexp_replace(a,',',''))+1)) connect by level<=length(str)) group by rn,lvl order by lvl asc) where cnt<>1)) x left join t y on 1=1;

RETURNVALUE
--------------------------------------------------------------------------------
asd
本回答被提问者和网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式