session.query( func.sum(x.amount).label('tot_amount'), x.id ).
filter(x.date>fromdate).filter(x.date wrote:
> And you do need to quote the column name in order_by also.
>
> session.query(func.sum(X.amount).label('tot_amount')).group_by(X.date).order_by('tot_amount').limit(10)
>
> generates code
>
And you do need to quote the column name in order_by also.
session.query(func.sum(X.amount).label('tot_amount')).group_by(X.date).order_by('tot_amount').limit(10)
generates code
SELECT sum(x.amount) AS tot_amount
FROM x GROUP BY x.date ORDER BY tot_amount
LIMIT 10 OFFSET 0
--~--~-~--~-
> -Original Message-
> From: sqlalchemy@googlegroups.com
> [mailto:sqlalch...@googlegroups.com] On Behalf Of rajasekhar911
> Sent: 17 November 2009 11:32
> To: sqlalchemy
> Subject: [sqlalchemy] Re: column label and order by
>
>
> anyone??
>
> On Nov
anyone??
On Nov 14, 6:48 pm, rajasekhar911 wrote:
> 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