[web2py] Re: order by the greater of 2 fields

2016-10-26 Thread Anthony Smith
On Wednesday, 26 October 2016 15:25:35 UTC+11, Anthony wrote: > > Hi all, >> This gets the results using sql but only able to do one or the other is >> the controller in web2py >> select * from animalTask order by >> GREATEST(COALESCE(withhold_until_date,0),COALESCE(esi_withhold_until_date,0))

[web2py] Re: order by the greater of 2 fields

2016-10-25 Thread Anthony
> > Hi all, > This gets the results using sql but only able to do one or the other is > the controller in web2py > select * from animalTask order by > GREATEST(COALESCE(withhold_until_date,0),COALESCE(esi_withhold_until_date,0)) > DESC > What do you mean by "one or the other" -- what is "the

[web2py] Re: order by the greater of 2 fields

2016-10-25 Thread Dave S
On Tuesday, October 25, 2016 at 3:56:42 AM UTC-7, Anthony Smith wrote: > > > Hi all, > This gets the results using sql but only able to do one or the other is > the controller in web2py > select * from animalTask order by > GREATEST(COALESCE(withhold_until_date,0),COALESCE(esi_withhold_until_d

[web2py] Re: order by the greater of 2 fields

2016-10-25 Thread Anthony Smith
On Tuesday, 25 October 2016 01:16:19 UTC+11, Anthony wrote: > > On Monday, October 24, 2016 at 7:11:29 AM UTC-4, Anthony Smith wrote: >> >> Hi all, >> >> I have table with 2 fields, withhold _until_date and esi_withhold_until. >> >> Is is it possible to order by so the the greater of the 2 fields

[web2py] Re: order by the greater of 2 fields

2016-10-24 Thread Anthony
On Monday, October 24, 2016 at 7:11:29 AM UTC-4, Anthony Smith wrote: > > Hi all, > > I have table with 2 fields, withhold _until_date and esi_withhold_until. > > Is is it possible to order by so the the greater of the 2 fields was at > the top of the list. > I think there are various ways to ach

[web2py] Re: order by the greater of 2 fields

2016-10-24 Thread Anthony
On Monday, October 24, 2016 at 8:55:23 AM UTC-4, 黄祥 wrote: > > pls try (not tested) > myorder = db.mytable.withhold_until_date | db.mytable.esi_withhold_until > db().select(db.mytable.ALL, orderby = myorder) > That will order by withhold_until_date, with esi_withhold_until breaking any ties -- it

[web2py] Re: order by the greater of 2 fields

2016-10-24 Thread 黄祥
pls try (not tested) myorder = db.mytable.withhold_until_date | db.mytable.esi_withhold_until db().select(db.mytable.ALL, orderby = myorder) ref: http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer best regards, stifan -- Resources: - http://web2py.com - http://web2py.c