Hi!
I have this query:
q1 = (s.query()
.add_columns(
Movement.customer_id,
Movement.document_id,
func.sum(Movement.debt).label('debt_moved'),
literal(0.00).label('debt_total')
)
.group_by(Movement.customer_id, Movement.document_id)
)
q2 = (s.query().
add_columns(
Debt.customer_id,
Debt.document_id,
literal(0.00).label('debt_moved'),
Debt.debt.label('debt_total'),
)
)
q3 = q1.union(q2)
The problem is that I need to SUM() the resulting query (columns
'debt_moved', 'debt_moved' should be summed, grouped by customer_id,
document_id), but so far all my attempts to use add_columns() and
group_by() on q3 have failed. How should I handle this this?
--
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.