Reputation: 14264
I'm not sure why this won't work:
SELECT u.id, u.tag, u.unit_type, Count(p.id) AS num_points
FROM ot2.unit u
INNER JOIN ot2.point p on p.unit_id = u.id
GROUP BY u.id
HAVING Count(p.id) > 800;
ERROR: column "u.tag" must appear in the GROUP BY clause or be used in an aggregate function SQL state: 42803
I have already provided a column for group by.
Upvotes: 1
Views: 2794
Reputation: 5370
Just what the error says. u.tag is not in the group by and you aren't telling how to aggregate the different u.tag values to a single one.
More concrete you have 2 options:
Upvotes: 2