Sure i don't mind an enhancement to text(), a method like as_subquery(c1, c2 
...) that turns it into a FromClause


On Nov 29, 2013, at 4:20 AM, Chris Withers <ch...@simplistix.co.uk> wrote:

> On 29/11/2013 05:09, Michael Bayer wrote:
>> 
>> On Nov 28, 2013, at 7:54 PM, Chris Withers <ch...@simplistix.co.uk> wrote:
>> 
>>> So far, I got:
>>> 
>>>    inst = aliased(Part)
>>>    unit = aliased(Part)
>>>    query = session.query(
>>>        inst.idea_id,
>>>        inst.instrument_id,
>>>        func.sum(inst.quantity),
>>>        func.sum(unit.quantity).alias('cost’),
>> 
>> bzzt - when you say func.foo(x).alias(), you’re interpreting the Function as 
>> a “SELECT * FROM func AS foo” type of thing.  Use func.sum(..).label(‘cost’).
> 
> Cool, that was it...
> 
> ...but does illustrate my point: the query is already fiddley, I managed to 
> get it working in sql, then I have to figure out how to re-express in 
> sqlalchemy.
> 
> Chris
> 
> -- 
> Simplistix - Content Management, Batch Processing & Python Consulting
>            - http://www.simplistix.co.uk
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sqlalchemy+unsubscr...@googlegroups.com.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> Visit this group at http://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/groups/opt_out.

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to