Jump to content
Marcelo Okada

Linhas em colunas

Recommended Posts

boa tarde, gostaria de saber como  q eu faço para transformar linhas em colunas.

 

 

data                    valor

06/02/2017       6,96

02/03/2017       8,50

 

trazer assim:  data                valor        data                  valor

                         06/02/2017   6,96         02/03/2017    8,50

 

no caso se tiver mais linhas assim indo incrementando na frente.

 

meu select 

SELECT HSSPAGA.DPAGAPAGA, 
       SUM(HSSPACON.NVALOPACON) SOMA_COPART
  FROM HSSPACON, HSSCONT, HSSPAGA
 WHERE HSSPACON.NNUMECONT = HSSCONT.NNUMECONT
   AND HSSCONT.NNUMEUSUA IN
       (SELECT NNUMEUSUA FROM HSSUSUA WHERE NNUMETITU = 4118333)
   AND HSSPAGA.NNUMEPAGA = HSSPACON.NNUMEPAGA
   AND HSSPAGA.DVENCPAGA BETWEEN '01/01/2016' AND '31/12/2017'
   AND HSSPAGA.NNUMEPAGA NOT IN (SELECT NNUMEPAGA FROM HSSPARCM)
   AND HSSPAGA.CFLAGPAGA IN ('P')
   AND HSSCONT.NNUMEUSUA = '28701'
   AND HSSPAGA.DVENCPAGA = '31/07/17'
 GROUP BY HSSPAGA.DPAGAPAGA
 ORDER BY DPAGAPAGA ASC

 

Share this post


Link to post
Share on other sites

o problema q nao sei como fazer isso, tentei de alguma forma nao traz resultado, 

 


SELECT HSSPAGA.DPAGAPAGA, 
       SUM(HSSPACON.NVALOPACON) SOMA_COPART
  FROM HSSPACON, HSSCONT, HSSPAGA
       UNPIVOT(NVALOPACON for DPAGAPAGA in(DPAGAPAGA))
 WHERE HSSPACON.NNUMECONT = HSSCONT.NNUMECONT
   AND HSSCONT.NNUMEUSUA IN
       (SELECT NNUMEUSUA FROM HSSUSUA WHERE NNUMETITU = 4118333)
   AND HSSPAGA.NNUMEPAGA = HSSPACON.NNUMEPAGA
   AND HSSPAGA.DVENCPAGA BETWEEN '01/01/2016' AND '31/12/2017'
   AND HSSPAGA.NNUMEPAGA NOT IN (SELECT NNUMEPAGA FROM HSSPARCM)
   AND HSSPAGA.CFLAGPAGA IN ('P')
   AND HSSCONT.NNUMEUSUA = '28701'
   AND HSSPAGA.DVENCPAGA = '31/07/17'
 GROUP BY HSSPAGA.DPAGAPAGA
 ORDER BY DPAGAPAGA ASC

 

 

 

OBS, SOU LEIGO EM ORACLE

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

Ao usar o fórum, você concorda com nossos Terms of Use.