Hi,
My SQL is like select host, count(*) as cnt from tbl group by host order
by cnt desc
How to achieve this using ORM?
session.query(Tbl.host,
func.count('*').label('cnt')).group_by(Tbl.host).order_by(???)
I don't wanna type again func.count... in order_by().
Thanks.
--
You received this
On Jan 7, 2013, at 9:19 PM, Ji Zhang wrote:
Hi,
My SQL is like select host, count(*) as cnt from tbl group by host order by
cnt desc
How to achieve this using ORM?
session.query(Tbl.host,
func.count('*').label('cnt')).group_by(Tbl.host).order_by(???)
I don't wanna type again
The second one is neat. Thanks~
On Tuesday, January 8, 2013 11:28:34 AM UTC+8, Michael Bayer wrote:
On Jan 7, 2013, at 9:19 PM, Ji Zhang wrote:
Hi,
My SQL is like select host, count(*) as cnt from tbl group by host
order by cnt desc
How to achieve this using ORM?