Topic: Combine select, order and group clause with postgresql (pg gem)
I can't figure out the right syntax to use with order, group and select clause. The below one raises an error on Postgresql DB:
@operations = Operation.unscoped.includes(:client).order("clients.lastname").select("client_id, sum(total) as total").group("client_id")The models are defined as follows:
class Client < ActiveRecord::Base
has_many :operations, dependent: :destroy
default_scope order: 'clients.lastname'
end
class Operation < ActiveRecord::Base
belongs_to :client
default_scope order: 'operations.value_date DESC'
endIt works on sqlite3 but fails on postgresql.
Any idea? Thank you.
Last edited by Javix (2012-10-25 03:28:38)