Here is an snippet from heroku logs:
ActiveRecord::StatementInvalid (PG::GroupingError: ERROR: column "stats.Season2dateMean" must appear in the GROUP BY clause or be used in an aggregate function
app[web.1]: LINE 1: SELECT "stats"."Season2dateMean", "stats"."Season2dateOFFMea...
app[web.1]: : SELECT "stats"."Season2dateMean", "stats"."Season2dateOFFMean", "stats"."Season2dateDEFMean" FROM "stats" GROUP BY "stats"."team1" HAVING created_at = MAX(created_at)):
Below is the excerpt from my controller file where the error occurs:
Return all Stats and group results by team1 attribute
@a = Stat.all
@b = @a.group("stats.team1")
Find last created record for each team
@c = @b.having("created_at = MAX(created_at)")
Return an array of the three selected attributes
@teamValues = @c.pluck("Season2dateMean", "Season2dateOFFMean", "Season2dateDEFMean")
How would I correct this error or is it not possible?