Return a single line where it currently returns 2 or more

-3

I'm trying to get a die, but it doubles when I try to do it. It duplicates if PARC_COD is the same, but should only bring the sum of the return value column on a line indifferent to what it has next. I just need a column.

Here's an example of how it works:

This is the result within left join

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

    
asked by anonymous 04.06.2018 / 17:36

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 
    
05.06.2018 / 14:22