Xavier,

select
 ID,
 description,
 if (ifnull(date1, 20201231) < ifnull(date2, 20201231), ifnull(date1,
20201231), ifnull(date2, 20201231)) as date
from MyTable
order by date

I didn't test it, but it should work.
Any questions? don't hesitate to ask.

Best regards,
Mikhail.


----- Original Message -----
From: "Xavier NOPRE" <[EMAIL PROTECTED]>
To: "Mailing list MySql" <[EMAIL PROTECTED]>
Sent: Tuesday, September 03, 2002 11:18 AM
Subject: Order by date


> Hi,
>
> I have a query from tables that give me records with two date "date1" and
> "date2". How can I order the records by the most recent date (between the
> two date) for each records ? Example:
>
> Data:
>
> ID    description    date1            date2
> 1      aaa                09/03/02       09/05/02
> 2      bbb                                       09/04/02
> 3      ccc                 09/02/02       09/10/02
>
> Result:
>
> ID    description    date
> 3      ccc                 09/02/02
> 1      aaa                09/03/02
> 2      bbb                09/04/02
>
> Thanks
>
> Xavier
>
>
>
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail
<[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to