Rails (PG::GroupingError: ERROR: column must appear in the GROUP BY clause or be used in an aggregate function
问题 In my local this query work perfect with sqlite3 def Event.most_like select("events.*, count(like_events.event_id) as likes_count") .joins(:like_events).group(:event_id).order("likes_count DESC").limit(4) end but i got some error when deploy heroku PG::GroupingError: ERROR: column "events.id" must appear in the GROUP BY clause or be used in an aggregate function Can someone help me fix this? 回答1: As the message, all fields in Select clause must appear in the GROUP BY or in aggregate function.