Error Invalid 'EXAMPLE' column in the selection list because it is not contained in an aggregation function or in the GROUP BY clause

Asked

Viewed 481 times

0

Hello, friends. I am trying to perform a query on SQL SERVER that worked perfectly on Sqlite. Does anyone know how to make it work?

Consultation:

SELECT B.CLIENTE, A.CODCLI, SUM(A.VALOR-A.VALORPAGO) AS 'A RECEBER'
FROM ARGCONTASRECEBER A
INNER JOIN ARGCLIENTE B
ON A.CODCLI = B.CODCLI
WHERE A.VALORPAGO < A.VALOR
GROUP BY A.CODCLI

Error:

Message 8120, Level 16, Status 1, Line 1 The column 'ARGCLIENTE.CLIENT' is invalid in the selection list because it is not contained in either an aggregation function or the GROUP BY clause.

Grateful from now on!

1 answer

2

You need to insert the client column into your GROUP BY, the updated query is as follows:

SELECT B.CLIENTE, A.CODCLI, SUM(A.VALOR-A.VALORPAGO) AS 'A RECEBER' FROM ARGCONTASRECEBER A INNER JOIN ARGCLIENTE B ON A.CODCLI = B.CODCLI WHERE A.VALORPAGO < A.VALOR GROUP BY B.CLIENTE, A.CODCLI

Browser other questions tagged

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