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.