How to select distinct from the Listagg function in the 12C database

Asked

Viewed 107 times

1

Is there any 12c bank function you can use on listagg and does not bring repeated results?

SELECT SUM(quantidade) quantidade,
      LISTAGG (mib.segment1, ' - ') WITHIN GROUP (ORDER BY ROWNUM) item,
      LISTAGG (mib.description, ' - ') WITHIN GROUP (ORDER BY ROWNUM) descricao                  
 FROM xg_tab_om_pedido_pneus a, 
      xg_tab_om_dpn_pedidos b,
      xg_tab_om_dpns cc,
      mtl_system_items_b mib
WHERE a.id_dpn_pedido = b.id_dpn_pedido
  AND b.id_dpn = cc.id_dpn
  AND mib.inventory_item_id = a.inventory_item_id
  AND mib.organization_id = c.ship_from_org_id

This query returns me repeated items, I would like the return is unique value.

1 answer

-1

Dude I believe no, what you can do is a wm_concat(distinct mib.segment1) and then give a replace na , by -, inside pro listagg I could never use distinct

Browser other questions tagged

You are not signed in. Login or sign up in order to post.