Home:ALL Converter>Rails/Postgres: Column must appear in group by clause

Rails/Postgres: Column must appear in group by clause

Ask Time:2011-10-27T23:09:39         Author:imderek

Json Formatter

So Postgres is complaining about:

PGError: ERROR:  column "sessions.created_at" must appear in the GROUP BY clause or be used in an aggregate function

But the trouble is, "created_at" does appear in the group by clause:

SELECT     created_at, count(id) as visit_count FROM       "sessions"  WHERE     ("sessions"."site_id" IN (4, 3)) AND ("sessions"."created_at" >= '2011-10-20 00:00:00.000000') AND ("sessions"."created_at" <= '2011-10-27 23:59:59.999999') GROUP BY  date(created_at))

Does it have something to do with created_at being wrapped in date() perhaps?

Thanks in advance!

Author:imderek,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/7918052/rails-postgres-column-must-appear-in-group-by-clause
yy