On Sep 12, 2005, at 8:43 AM, Jay Sprenkle wrote:

On 9/12/05, Puneet Kishor <[EMAIL PROTECTED]> wrote:

my table is

name (VARCHAR), created_on (DATETIME DEFAULT CURRENT_TIMESTAMP),
modified_on (DATETIME)

When a new record is created, it gets a value in the created_on col,
which is then not changed subsequently, but the modified_on col is
empty. Whenever the record is updated, the modified_on col is changed.

--I want the last 10 records



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

I didn't realize MAX could be used in ORDER BY.

However, the above does not work. It seems to overlook all the records which have a created_on date but no modified_on date. For example, even the most latest record created but not yet modified doesn't show up in the above query result. It seems to pull only those records which have a valid value for both created_on and modified_on columns.


--
Puneet Kishor

Reply via email to