mardi 28 juin 2016

Raw pg GROUP BY query in rails application

I have this very simple SQL query that i am trying to execute in my rails console.

SELECT name, manual_score FROM objectives GROUP BY manual_score

But it throws an error which is:

ActiveRecord::StatementInvalid: PG::GroupingError: ERROR:  column "objectives.name" must appear in the GROUP BY clause or be used in an aggregate function

I have tried by prepending table name with columns but the error remains. Any help would be appericiated. Thanks!

Aucun commentaire:

Enregistrer un commentaire