On Sep 12, 2005, at 8:54 AM, [EMAIL PROTECTED] wrote:

Jay Sprenkle <[EMAIL PROTECTED]> writes:

If you just want 10 records with the highest modified or created time I
think this will do it:

select *
from tbl
order by max(created_on,modified_on) desc
limit 10

except that if modified_on is null, you won't get that record. This variation
should fix that problem:


SELECT *
  FROM tbl
  ORDER BY MAX(created_on, COALESCE(modified_on, 0)) DESC
  LIMIT 10;


and so it does. Gracias. ;-)

Now I am off happily experimenting with applying other functions to ORDER BY before ordering them.


--
Puneet Kishor

Reply via email to