Query failed: ERROR: syntax error at or near "GROUP" LINE 1: ....distance from distance WHERE distance.tour_id = GROUP BY s... ^