Hi guys,
how do i apply order by on a column with a label.
My requirement is like this
class x
id,
amount,
date
i have to group based on id and take sum of amount within a date
range.
i am applying a label to sum of amount
now how do i order based on that so that i can get top 5 ..
session.query( func.sum(x.amount).label('tot_amount'), x.id ).
filter(x.date>fromdate).filter(x.date<todate).
.group_by(x.id)
.order_by(?????)
.limit(5)
thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---