On Mar 16, 2009, at 10:48 PM, Alisue wrote:

>
> Hey thanks! I figured out but I still don't know why...
>
> subquery = query.subquery()
> minroom = meta.Session.query(subquery.c.property_id, func.min
> (subquery.c.house_rent).label('minprice'))
> minroom = minroom.group_by(subquery.c.property_id)
> minroom = minroom.subquery()
> query = meta.Session.query(model.Room).join((minroom,
> (model.Room.property_id==minroom.c.property_id) &
> (model.Room.house_rent == minroom.c.minprice)))
> query = query.group_by(model.Room.property_id)
> # The lines below are the magic.
> subquery = query.subquery()
> query = meta.Session.query(model.Room)
> query = query.join((subquery, model.Room.id == subquery.c.id))
>
> I found it because 'len(query.all())' return the 'Correct Value' but
> 'query.count()'
> How did it happen? I cant' understand....

there's no "count" in there, so not enough detail is given here to  
determine how the SQL is generated (i.e. we can't see what "query"  
starts out as).



--~--~---------~--~----~------------~-------~--~----~
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