This is not a rails or postgres question. The query you are trying to
use will not work on any system.
You want to group data, therefore any fields you are grouping by must
appear in the output.
You need to change your thinking and probably use embedded sql not
depend on the rails generator.
On Oct 25, 2:26 pm, Craig White
<cr...-CnJ8jr4MGtxl57MIdRCFDg@public.gmane.org>
wrote:> 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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---