[sqlalchemy] Re: how can I do such a sorted query?

2007-11-08 Thread Rick Morrison
Most database engines support a couple of SQL functions that help in cases like this, read your database docs for either the ISNULL or the COALESCE function. Another technique is to use an SQL CASE statement. For all three methods the idea is to supply a default value to substitute when the

[sqlalchemy] Re: how can I do such a sorted query?

2007-11-08 Thread artman
Thanks for your help,Rick. Followed your advice, I've solved the problem. Following is the solution: select([table_name]).order_by(case([(table_name.c.s_date==None,table_name.c.f_date)],else_=table_name.c.s_date)) Thanks again :) On 11月9日, 上午1时48分, Rick Morrison [EMAIL PROTECTED] wrote: