I am not sure that this is entirely a rails question as I am trying to run the command in postgres and I am getting the same error...
controller code...
@client_slot_count = ClientSlotsDaily.find(:all, :conditions => ["created_at > ? AND created_at < ? AND facility_id = ? AND client_id IS NOT NULL", starting_date, ending_date, @facility.id], :group => 'client_id')
error reported is...
PGError: ERROR: column "client_slots_dailies.id" must appear in the GROUP BY clause or be used in an aggregate function : SELECT * FROM client_slots_dailies WHERE (created_at > '2007-05-01' AND created_at < '2007-07-01' AND facility_id = 1 AND client_id IS NOT NULL) GROUP BY client_id
Which I don't understand.
create_table "client_slots_dailies", :force => true do |t| t.column "name", :string, :limit => 7 t.column "facility_id", :integer t.column "placement_id", :integer t.column "client_id", :integer t.column "created_at", :datetime end
I can do ClientSlotsDaily.count etc. but not find as configured.
I don't want to keep hitting the DB and the group function made sense until I tried to use it.
Suggestions?
Craig