Re: [sqlite] SQL assistance with selecting the last n records inserted

2005-09-12 Thread Jay Sprenkle
> and so it does. Gracias. ;-) > > Now I am off happily experimenting with applying other functions to > ORDER BY before ordering them. Thanks Derrell. You've used your super powered intellect well today! ;) --- The Castles of Dereth Calendar: a tour of the art and architecture of Asheron's

Re: [sqlite] SQL assistance with selecting the last n records inserted

2005-09-12 Thread Puneet Kishor
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

Re: [sqlite] SQL assistance with selecting the last n records inserted

2005-09-12 Thread Jay Sprenkle
> > > > 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

Re: [sqlite] SQL assistance with selecting the last n records inserted

2005-09-12 Thread Derrell . Lipman
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

Re: [sqlite] SQL assistance with selecting the last n records inserted

2005-09-12 Thread Puneet Kishor
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

Re: [sqlite] SQL assistance with selecting the last n records inserted

2005-09-12 Thread Jay Sprenkle
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

[sqlite] SQL assistance with selecting the last n records inserted

2005-09-12 Thread Puneet Kishor
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