Skip to content

Instantly share code, notes, and snippets.

@AndrewVos
Created December 4, 2014 14:48
Show Gist options
  • Save AndrewVos/64914529e9936f7ac562 to your computer and use it in GitHub Desktop.
Save AndrewVos/64914529e9936f7ac562 to your computer and use it in GitHub Desktop.
[8] pry(main)> Activity.group(:product_id).order(created_at: :desc)
Activity Load (1.1ms) SELECT "activities".* FROM "activities" GROUP BY product_id ORDER BY "activities"."created_at" DESC
PG::GroupingError: ERROR: column "activities.id" must appear in the GROUP BY clause or be used in an aggregate function
LINE 1: SELECT "activities".* FROM "activities" GROUP BY product_id...
^
: SELECT "activities".* FROM "activities" GROUP BY product_id ORDER BY "activities"."created_at" DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment