> > > > 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.
Oh. Sorry, forgot about NULLS :( You could either wrap the modified_on field with a function to return the creation date if it's null, or assign a modified date to every record equal to the create date when the record is created.