Oracle
 sql >> Base de Dados >  >> RDS >> Oracle

SSIS:Oracle Multiple rows to one column output sem STRAGG


Existem várias maneiras de realizar a agregação de strings para produzir uma lista separada por vírgulas - veja este link para mais detalhes . Com base no exemplo do link, tente:
SELECT x.id,
       LTRIM(MAX(SYS_CONNECT_BY_PATH(x.language,','))
       KEEP (DENSE_RANK LAST ORDER BY curr),',') AS employees
  FROM (SELECT a.id,
               b.language,
               ROW_NUMBER() OVER (PARTITION BY a.id ORDER BY b.language) AS curr,
               ROW_NUMBER() OVER (PARTITION BY a.id ORDER BY b.language) -1 AS prev
          FROM TABLE_1 a
          JOIN TABLE_2 b ON b.id = a.langid) x
GROUP BY x.id
CONNECT BY prev = PRIOR curr AND x.id = PRIOR x.id
START WITH curr = 1;