• 0
Sign in to follow this  
Dwry Stos

Juntar dados de uma coluna em duas linhas


Boa tarde , 

Gostaria de saber como juntar dados de duas linhas em uma coluna tipo assim eu tenho a seguinte view:

SELECT     pch01_1.pch01_doc_id AS ID, pch01_1.pch01_rq_doc_id AS Numero_RC, pch01_1.pch01_std_dtn_area AS Area_CAR, pch01_1.pch01_rq_dt AS Data_Req, 
                      SUBSTRING(pch01_1.pch01_doc_id, 1, 4) AS Ano, pchsla_1.pchsla_it_id AS Cod_Material, pchsla_1.pchsla_it_nb AS Item, 
                      pchsla_1.pchsla_it_dsc AS Descricao_resumida, pchsla_1.pchsla_it_qt AS Qtde, pchsla_1.pchsla_it_mun AS UM, pchsla_1.pchsla_it_amt / 100 AS Val_Unit, 
                      pchsla_1.pchsla_it_tot_amt / 100 AS Val_Total, matdf_1.matdf_id_ctry, pchsla_1.pchsla_st AS Status, combmmt_1.cobmmt_txt_seq AS Seq, 
                      combmmt_1.cobmmt_txt AS Descricao
FROM         WNSPGEMPRD1.GEMPRD1.dbo.pch01 AS pch01_1 INNER JOIN
                      WNSPGEMPRD1.GEMPRD1.dbo.pchsla AS pchsla_1 ON pch01_1.pch01_doc_id = pchsla_1.pchsla_doc_id INNER JOIN
                      WNSPGEMPRD1.GEMPRD1.dbo.matdf AS matdf_1 ON pchsla_1.pchsla_it_id = matdf_1.matdf_id INNER JOIN
                      WNSPGEMPRD1.GEMPRD1.dbo.cobmmt AS combmmt_1 ON matdf_1.matdf_cmpl_id = combmmt_1.cobmmt_id
WHERE     (pchsla_1.pchsla_st <> 'C') AND (combmmt_1.cobmmt_cl = 'MATDF')

gostaria de juntar assim : nas colunas cobmmt_txt_seq informa a sequencia do complemento das informações contidas na coluna e cobmmt_txt, então gostaria de que quando aparecer na coluna  cobmmt_txt_seq sequencia 1,2,3 etc que a coluna cobmmt_txt junta-se as informações das linha abaixo conforme a sequencia.

Como fazer isso?

desde já agradeço.

Edited by Dwry Stos

Share this post

Link to post
Share on other sites

1 answer to this question

Recommended Posts

Join the conversation

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

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.

Sign in to follow this