gpt4 book ai didi

sql - Oracle SQL 从表中获取唯一符号

转载 作者:行者123 更新时间:2023-12-03 02:02:25 26 4
gpt4 key购买 nike

我有一个带有某些描述的表格。例如:

My_Tableid   description================1    ABC2    ABB3    OPAC4    APEЧ

我需要从所有“描述”列中获取所有唯一符号。结果应该如下所示:

symbol================ABCOPEЧ

它应该适用于所有语言,所以,据我所知,正则表达式无济于事。请帮我。谢谢。

最佳答案

with    cte (c,description_suffix) as
(
select substr(description,1,1)
,substr(description,2)
from mytable
where description is not null

union all

select substr(description_suffix,1,1)
,substr(description_suffix,2)
from cte
where description_suffix is not null
)
select c
,count(*) as cnt
from cte
group by c
order by c

with    cte(n) as
(
select level
from dual
connect by level <= (select max(length(description)) from mytable)
)
select substr(t.description,c.n,1) as c
,count(*) as cnt
from mytable t
join cte c
on c.n <= length(description)
group by substr(t.description,c.n,1)
order by c
<小时/>
+---+-----+
| C | CNT |
+---+-----+
| A | 4 |
| B | 3 |
| C | 2 |
| E | 1 |
| O | 1 |
| P | 2 |
| Ч | 1 |
+---+-----+

关于sql - Oracle SQL 从表中获取唯一符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43483151/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com