On Saturday 06 June 2009 17.39:20 naktinis wrote: > I think this was not the case, since I didn't expect the merged result > to be ordered. > > To be more precise, the query looks like: > q1 = Thing.query().filter(...).order_by(Thing.a.desc()).limit(1) > q2 = Thing.query().filter(...).order_by(Thing.a.asc()).limit(1) > q = q1.union(q2).order_by(Thing.id).all() > > The q1 returns first filtered element with largest 'a' column, q2 - > first with smallest 'a'. > > So, I guess my question is still valid.
You didn't mention limit in your first post, so I misunderstood what you were trying to do, sorry. Yes, as Michael said, subqueries are the way to go. I'm quite new to sa, so I can't help you there. cheers -- vbi -- featured link: http://www.pool.ntp.org
signature.asc
Description: This is a digitally signed message part.