On Oct 11, 2008, at 10:01 PM, Jonathan Ellis wrote:

>
> On Sat, Oct 11, 2008 at 7:41 PM, Jonathan Ellis <[EMAIL PROTECTED] 
> > wrote:
>> I want to do something like this:
>>
>> select ticket.*, (select count(*) from ticket_changes where
>> ticket_changes.ticket = ticket.id) as count
>> from ticket
>
> Justin solved this in IRC.  The answer is,
>
>>>> subquery = select([func.count('*')], from_obj=ticket_changes)
>>>> session.query(Ticket, subquery.as_scalar()).first()
>

theres no WHERE clause on your subquery there.  I think google groups  
is  delivering mail very crappily this week but i had mentioned  
".where(ticket_changes.c.ticket_id==Ticket.id)" as part of the subquery.

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to