Return a single line where it currently returns 2 or more

Asked

Viewed 546 times

-3

I’m trying to bring a die, but it doubles when I try to do it. It doubles if the PARC_COD is the same, but should only bring the sum of the return value column in a row indifferent to what is next to it. I only need one column.

Follow an example of how this:

inserir a descrição da imagem aqui

This is the result within a left join

I need to add the return value to bring in only one line without duplicates.

  • What is the criterion for bringing a line ? the largest ? the most recent ? grouped by line , pivoted ?

  • Hello I need the return value to be added because if VC notice it is displaying 2x the value of 1502 and is not if not the report gets wrong. Then I’m not getting it

  • There are two return notes for the same data set. Add the SQL code and post information about the tables involved. Otherwise, there is no help. // Also inform which is the database manager (Mysql, Oracle Database, SQL Server etc)

  • It would be in thesis a GROUP BY with SUM.

1 answer

0

SELECT 
                                  PARCEIROID
                                ,NFFE_VAL_MER =SUM(NFFE_VAL_MER)
                                 FROM TSTQ_NFFENT 
                                 WHERE  
    CONVERT(CHAR(08),NFFE_DAT_ENT,112 ) BETWEEN @vDATA_INI AND @vDATA_FIM 
                                      AND  STNE_COD =4 
                                        AND NFFE_SER <> 'CAN'  
                                        AND NFFE_CHR_ESPDOC ='NFE' 

                                        GROUP BY  PARCEIROID --estava errando aqui  onde estava adicionando  as 2 colunas na subquery e só precisava adicionar o `PARCEIROID` para conseguir retorno de uma linha 

Browser other questions tagged

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