Skip to content

Instantly share code, notes, and snippets.

@x-yuri
Last active August 23, 2018 14:42
Show Gist options
  • Select an option

  • Save x-yuri/0cfd472ca68505c8cf5ebd90841127bf to your computer and use it in GitHub Desktop.

Select an option

Save x-yuri/0cfd472ca68505c8cf5ebd90841127bf to your computer and use it in GitHub Desktop.
ERROR: aggregate functions are not allowed in GROUP BY
$ psql db -c "select char_length(string_agg(legacy_id, ', ')) from products group by 1"
ERROR: aggregate functions are not allowed in GROUP BY
LINE 1: select char_length(string_agg(legacy_id, ', ')) from products...
^
$ psql db -c "select char_length(string_agg(legacy_id, ', ')) from products group by TRUE"
char_length
-------------
15666
(1 row)
$ psql --version
psql (PostgreSQL) 10.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment