This is a discussion on Order by the biggest of 2 fields within the MySQL Database forums, part of the Database Forums category; I've a query where I've 2 dates fields in the result. I'd like to order the query ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I've a query where I've 2 dates fields in the result.
I'd like to order the query result using the biggest value from those fields on every record. something like order by (may(dateA,dateB)) desc. So it orders by the biggest date of every record, no importance if the biggest is the DateA or DateB. How to do so ? It is possible ? Thanks for helping. Bob |
|
|||
|
On 6 Sep, 13:29, "Bob Bedford" <b...@bedford.com> wrote:
> I've a query where I've 2 dates fields in the result. > > I'd like to order the query result using the biggest value from those fields > on every record. > > something like order by (may(dateA,dateB)) desc. > > So it orders by the biggest date of every record, no importance if the > biggest is the DateA or DateB. > > How to do so ? It is possible ? > > Thanks for helping. > > Bob well you could do it like: SELECT IF(datea > dateb, datea, dateb) obd, other_field FROM table ORDER BY 1 |
|
|||
|
"Captain Paralytic" <paul_lautman@yahoo.com> a écrit dans le message de
news: 1189083250.835700.76250@o80g2000hse.googlegroups.c om... > On 6 Sep, 13:29, "Bob Bedford" <b...@bedford.com> wrote: >> I've a query where I've 2 dates fields in the result. >> >> I'd like to order the query result using the biggest value from those >> fields >> on every record. >> >> something like order by (may(dateA,dateB)) desc. >> >> So it orders by the biggest date of every record, no importance if the >> biggest is the DateA or DateB. >> >> How to do so ? It is possible ? >> >> Thanks for helping. >> >> Bob > > well you could do it like: > SELECT > IF(datea > dateb, datea, dateb) obd, > other_field > FROM table > ORDER BY 1 It was that simple....thanks for your help Captain. |