Return multiple lines, in a single comma separated by ORACLE

Asked

Viewed 60 times

0

I need to bring these results, in a single line, where it is only separated by a comma,
how do I do that?

inserir a descrição da imagem aqui

Query:

SELECT '       '|| (SELECT DECODE(MAX(g.ds_opcao),NULL,'',MAX(g.ds_opcao)||' - ') FROM nut_opcao g WHERE g.nr_sequencia = c.nr_seq_opcao_sel) ||
SUBSTR(e.ds_receita,1,255)ds_cardapio 
FROM     nut_pac_opcao_rec c,
        nut_atend_serv_dia d,
    nut_receita e
WHERE    c.NR_SEQ_SERVICO_DIA = d.nr_sequencia
and    c.nr_seq_receita = e.nr_sequencia
and    nvl(e.ie_situacao, 'A') = 'A'
AND        NVL(ie_receita_especial,'N') = 'N'
AND        d.dt_servico BETWEEN TO_DATE(:DT_SERVICO) AND TO_DATE(:DT_SERVICO) + 86399/86400
AND        d.nr_seq_servico = :nr_servico_p
AND        d.nr_atendimento = :nr_atendimento_p
ORDER BY ds_cardapio[![inserir a descrição da imagem aqui][1]][1]
  • this is called "pivot", look for pivot here on the site or google for "pivot oracle"

  • 1

    Search by LISTAGG https://docs.oracle.com/cd/E11882_01/server.112/e41084/functions089.htm#SQLRF30030

  • i got with listagg, mt thanks

No answers

Browser other questions tagged

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