ERROR: column "a.order" must appear in the GROUP BY clause or be used in an aggregate function