An event has a column popularityand many keywords. The keyword has a category and a name. I try to sort events by their popularity, but then I return the most popular event from each keyword with the category "taxonomy".
Here is my request:
Event.order(:popularity).joins(:keywords).where(keywords: {category: "taxonomy"}).group("keywords.name")
But I get below the error:
PG :: GroupingError: ERROR: the column "events.id" should appear in the GROUP BY group or be used in an aggregate function
Where am I going wrong?
source
share