Could you point me to the url where this example is? I wonder why
order_by and other things work with the ORM then and group_by left out
Thanks
On Jun 28, 1:19 am, Huy Do <[EMAIL PROTECTED]> wrote:
> I think you should listen to that error message.
>
> user.id must appear in the "group by" or be used in an aggregate
> function i.e count, sum, avg etc.
>
> The other problem you are using the ORM interface. You should be using
> the SQL select.
>
> I'm not sure what you are trying to achieve, but your original query
> does not make sense from any SQL perspective.
>
> This is an example from the docs on how to use group by from an SQL select.
>
> s = select([customers,
> func.count(orders).label('order_count'),
> func.max(orders.price).label('highest_order')],
> customers.c.customer_id==orders.c.customer_id,
> group_by=[c for c in customers.c]
> ).alias('somealias')
>
> Huy
>
> > Then it must be a bug, I still get an error
>
> > _execute build\bdist.win32\egg\sqlalchemy\engine\base.py 602
> > "SQLError: (ProgrammingError) column ""user.id"" must appear in the
> > GROUP BY clause or be used in an aggregate function
>
> > On Jun 27, 9:09 pm, Andreas Jung <[EMAIL PROTECTED]> wrote:
>
> >> --On 27. Juni 2007 12:00:13 -0700 voltron <[EMAIL PROTECTED]> wrote:
>
> >>> I´m guessing a bit because I still could not find the group_by entry
> >>> in the docs
>
> >>> This works:
> >>> user.select(links.c.id> 3, order_by=[user.c.id]).execute()
>
> >>> but this does not
> >>> user.select(links.c.id> 3,group_by=[user.c.dept]).execute()
>
> >>> What should be the right syntax?
>
> >> Works for me:
>
> >> for row in session.query(am).select(am.c.hidx=='HI1561203',
> >> group_by=[am.c.hidx]):
> >> print row.hidx, row.versionsnr
>
> >> -aj
>
> >> application_pgp-signature_part
> >> 1KDownload
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---