[sqlalchemy] Re: group_by argument as a result of a query

2011-08-15 Thread Eduardo
Here is the example: column_names = session.query(tab.c.name).filter(tab.c.value==354) column_names = [column_name for (column_name,) in column_names] query=sess.query(func.max(tab.columns['name']),datab.columns['article_id']).group_by(*column_names).all() I get an error here:

Re: [sqlalchemy] Re: group_by argument as a result of a query

2011-08-15 Thread Wichert Akkerman
On 08/15/2011 10:20 AM, Eduardo wrote: Here is the example: column_names = session.query(tab.c.name).filter(tab.c.value==354) column_names = [column_name for (column_name,) in column_names]

[sqlalchemy] Re: group_by argument as a result of a query

2011-08-15 Thread Eduardo
This I want to do: 1) I want to find all names that satisfy this query column_names = session.query(tab.c.name).filter(tab.c.value==354) 2) Among those rows I want to find those with the highest id ( all rows with the same name are fist grouped and only the one with the highest id is retained the

Re: [sqlalchemy] Re: group_by argument as a result of a query

2011-08-15 Thread Michael Bayer
On Aug 15, 2011, at 6:03 AM, Eduardo wrote: This I want to do: 1) I want to find all names that satisfy this query column_names = session.query(tab.c.name).filter(tab.c.value==354) 2) Among those rows I want to find those with the highest id ( all rows with the same name are fist grouped