Reputation: 1
Quer logs.type = apps.log_type
WHERE logs.datetime query
Quer logs.type = apps.log_type
WHERE logs.datetime
query enter code here
: the sql
Query not executing, unable to run in sql server
Upvotes: 0
Views: 86
Reputation: 173121
For GROUP BY to work it should be used along with aggregate functions in the SELECT list
Something like below example:
#standardSQL
SELECT
MAX(logs.datetime) latest_datetime,
logs.type,
SUM(LENGTH(logs.message)) messages_length,
apps.name
FROM logs INNER JOIN apps
ON logs.type = apps.log_type
WHERE logs.datetime > "2017-07-01T00:00:00"
AND logs.datetime < "2017-07-02T00:00:00"
GROUP BY apps.name, logs.type
so the rule of thumb is - any field in SELECT
statement should be either in GROUP BY
list or (if not in GROUP BY) to be used with Aggregate Function
Upvotes: 1