Skip to content
Advertisement

Postgres: avoid listing all columns (“must appear in the GROUP BY clause or be used in an aggregate function”)

This query works:

but it’s very explicit and I’d like it simplified to:

But this gives the error column "video_feed_unscored.title" must appear in the GROUP BY clause or be used in an aggregate function.

Any other way to simplify the query?

Advertisement

Answer

Maybe not simplify but assuming, that there is a lot of feeds, and user see only few of them, query below should have better execution plan (it’s worth to check).

Additionaly selecting columns any range of columns is no longer a problem

And there is always place for subquery (if execution plan is good enough)

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement