0
I’m having trouble executing an SQL query.
The consultation is:
SELECT DISTINCT CHAVE_FATO,COD_FILIAL,COD_DOCTO,NUM_DOCTO,DATA,VALOR_TOTAL,VALOR_LIQUIDO,COD_CLI_FOR,NOME_CLI_FOR,COD_VEND_COMP,NOME_VEND_COMP,COD_PRODUTO,DESC_PRODUTO_EST,NOME_SECAO,QTDE_UND,QTDE_PRI,QTDE_AUX,VALOR_UNITARIO,VALOR_TOTAL_ITEM
FROM [SATK].[dbo].entrada
WHERE DATA > '2018-01-01 00:00:00'
ORDER BY NUM_DOCTO ASC
Does not work, the return keeps showing repeated values in the NUM_DOCTO column.
I need to eliminate it, but I’m not getting it.
Distinct makes the distinction of EVERYTHING. And not just a column
– Leonardo Bonetti
You have to group columns by the GROUP BY clause which can be grouped together, others you can use MIN, MAX functions until you arrive at a result that suits you. But all columns have to be dealt with.
– Reginaldo Rigo