On 29/11/2013 05:09, Michael Bayer wrote:

On Nov 28, 2013, at 7:54 PM, Chris Withers <[email protected]> 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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to