0

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!

1 Answer 1

4

No, it does not appear.

The GROUP BY contains date(created_at) whereas your SELECT list only contains created_at. If created_at is a timestamp, then these are two different things.

You either need to use GROUPY BY created_at or SELECT date(created_at) (probably the latter)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.