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.
u.unit_type