【问题标题】:Remove duplicates in listagg?删除listagg中的重复项?
【发布时间】:2022-01-06 06:11:47
【问题描述】:

输入数据

ID   CID
1    101,103
1    101

在目标中,我是这样的,我使用了 listagg 函数

ID   CID
1    101,103,101

但我想要下面的输出

ID    CID
1    101,103

【问题讨论】:

    标签: informatica listagg


    【解决方案1】:

    先使用 distinct 然后使用 listag。可以参考下面的SQL。

    SELECT
     subqry.ID as id,
     listagg(cid,',') within group(order by(id)) as cid
    FROM 
    (select distinct ID, CID from FROM Table1) subqry -- this will deduplicate CIDs first
    group by id 
    Order by 1
    --
    

    【讨论】:

    • 我在子查询中使用 distinct 但输出仍然相同
    • 您能否在问题中发布您的查询/
    猜你喜欢
    • 2018-11-28
    • 1970-01-01
    • 2021-11-08
    • 1970-01-01
    • 2021-08-04
    • 2012-07-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多