【问题标题】:How remove duplicates from sql list? [duplicate]如何从 sql 列表中删除重复项? [复制]
【发布时间】:2023-03-03 07:47:30
【问题描述】:
<property name="xxDescribtionNumbers" formula="(
                select nvl(listagg(A.NUMBER, ', ') within group (order by A.NUMBER),' ') 
                from  ENTER E
                left outer join ADRESS A on A.ID = E.ADRESS_ID
                where E.BUILDING_ID = ID
                )" />

这将列出一个数字列表,但可以包含重复项,但我不想要任何重复项。

【问题讨论】:

    标签: sql oracle hibernate


    【解决方案1】:

    您可以通过删除子查询中的值来做到这一点:

    select coalesce(listagg(va.CISLO, ', ') within group (order by va.CISLO), ' ') 
    from (select distinct a.cislo
          from VCHOD V left join
               ADRESA A
               on A.ID = V.ADRESA_ID
          where V.BUDOVA_ID = ID
         ) va;
    

    【讨论】:

    • 当我使用它时它不起作用,因为我无法知道第一行的 A.CISLO,“%s: invalid identifier”
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-07
    • 1970-01-01
    • 2011-02-20
    相关资源
    最近更新 更多