Dear all,
I have the following query that is made of 3 queries on only ONE
TABLE:

1. Step simple normal query

somequery=session.query(tab.columns['name'],tab.columns['id']).filter(tab.columns['value']=="6")

2. Step: finding the max serial number for each serie

maxquery=session.query(func.max(tab.columns['serial_number']),datab.columns['serie']).group_by(datab.columns['serie'])

3. Step: find name and id of each row satisfying query from Step1
having maximal serial number in a serie
finalquery=somequery.filter(tuple_(tab.columns['serial_number'],datab.columns['serie']).in_(fidq))

Is there any more efficient way to do this? I am especially not
thrilled with the step 3 (creating tuples and then searching
equivalents from the results of the query 2). I think it is very cost-
intensive.

Remark: All rows with the same name and id also have the same serie
attribute.

Thanks


-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to