I get the following error.
[Microsoft] [ODBC SQL Server Driver] [SQL Server] The column "STATS.VisitorIP" is not valid in the selection list because it is neither contained in the aggregate function nor in the GROUP BY clause.
I used the VISITORIP column in both select lists. I used the GROUP BY clause in one of them, so I added VISITORIP to it. But I do not have a GROUP BY clause in another select, so he did not add it. Why am I getting this error?
SELECT S.VISITORIP, S.HTTPADDRESS, S.DATEENTERED
FROM STATS S
JOIN (SELECT S1.VISITORIP, MAX(S1.DATEENTERED) FROM STATS S1 WHERE DATEENTERED BETWEEN '" & OnlineTime & "' AND '" & NOW() & "') S1
ON S.VISITORIP = S1.VISITORIP AND S.DATEENTERED = S1.DATEENTERED
WHERE S.DATEENTERED BETWEEN '" &TIME& "' AND '" & NOW() & "'
GROUP BY S.VISITORIP, S.HTTPADDRESS, S.DATEENTERED
ORDER BY S.DATEENTERED DESC
Zonar
source
share