2
I need to make a select with JOIN
in two tables but I am not able to group to not repeat the lines. Follows the expression SQL:
SELECT
Andamento.NumeroProcesso,
Andamento.Chave,
Andamento.Codigo,
Andamento.DataAnda,
Andamento.Andamento,
Andamento.AdvogadoID
FROM Andamento FULL OUTER JOIN Processo
ON Andamento.NumeroProcesso = Processo.NumeroProcesso
WHERE (Processo.Irrecuperavel = 1) AND (DATEDIFF(MONTH,
Andamento.DataAnda,GETDATE()) >= 6)
When I try the clause:
GROUP BY Andamento.NumeroProcesso
I get the following error:
The 'Progress.Key' column is invalid in the selection list because it is not contained in an aggregation function or clause
GROUP BY
has already tried to put, GROUP BY Andamento.Numeroprocesso, Andamento.Chave ?
– Victor
The solution will vary according to the relationship and data of these tables, try to include in the question the expected result. But one thing is certain the group by syntax should contain all fields that are not continuous in an aggregation function.
– Caique Romero