随笔 - 28  文章 - 0  评论 - 1  阅读 - 8681

分组拼接字符串去重

1、只分组拼接不去重

select a.si_item_id,b.si_item_name,listagg(c.si_item_name, ',') within group(order by c.si_item_name)
from ybsh_base.t_reg_si_item_rel a ,t_reg_si_item b,t_reg_si_item c where  a.si_item_id=204276 --86650
and a.si_item_id=b.si_item_id and a.rel_si_item_id=c.si_item_id
group by a.si_item_id, b.si_item_name

 

显示

 

 2、分组拼接再去重

select a.si_item_id,b.si_item_name,to_char(wm_concat(distinct c.si_item_name)) as si_item
from ybsh_base.t_reg_si_item_rel a ,t_reg_si_item b,t_reg_si_item c where 1=1  and  a.si_item_id=204276
and a.si_item_id=b.si_item_id and a.rel_si_item_id=c.si_item_id
group by a.si_item_id, b.si_item_name

显示

 

posted on   宇宇小子  阅读(53)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示