Jump to content
Fórum Script Brasil
  • 0

Trazer valores do mesmo campo em colunas


pechiski
 Share

Question

Tenho um script onde quero separar os valores de um mesmo campo da tabela em colunas, fiz o script abaixo que faz isso, mas traz em duas linhas queria trazem em uma linha somente

select r040fev.numcad Cadastro,
       r040fev.valeve Ferias,
       0 Abono
  from r040fev, r008evc
 where 0 = 1
 union
select r040fev.numcad,
       sum(r040fev.valeve),
       0
  from r040fev, r008evc
 where r040fev.inifer between '09/01/2015' and '09/30/2015'
   and r008evc.codtab = r040fev.tabeve
   and r008evc.codeve = r040fev.codeve
   and r008evc.crteve in ('01E','02E','11B','11C','11D','11F','11G','11H','11J')
 group by r040fev.numcad

 union all

select r040fev.numcad Cadastro,
       0 Ferias,
       r040fev.valeve Abono
  from r040fev, r008evc
 where 0 = 1
 union
select r040fev.numcad,
       0,
       sum(r040fev.valeve)
  from r040fev, r008evc
 where r040fev.inifer between '09/01/2015' and '09/30/2015'
   and r008evc.codtab = r040fev.tabeve
   and r008evc.codeve = r040fev.codeve
   and r008evc.crteve in ('12A','12B','12C','12D','12E','12G')
 group by r040fev.numcad

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Forum Statistics

    • Total Topics
      149.9k
    • Total Posts
      646.8k
×
×
  • Create New...