On 12 Jul 2016, at 12:25am, Keith Christian <keith1christ...@gmail.com> wrote:
> A table has a column of dates and times that look like this: > > 2015-10-02 07:55:02 > 2015-10-02 07:55:02 > 2015-10-02 10:00:03 > 2015-10-02 10:05:02 > 2015-10-02 10:10:02 > > > Schema: > CREATE TABLE general ( id integer primary key autoincrement, server > text, date_time_stamp text); > > > Would like to get the latest two dates and times, kept in ascending > order, e.g. the query should return these two values: > > 2015-10-02 10:05:02 > 2015-10-02 10:10:02 SELECT date_time_stamp FROM general ORDER BY date_time_stamp DESC LIMIT 2 The only difference is that the rows will always be in the reverse order to what you asked for: biggest timestamp first. But since it's consistent that shouldn't be a problem. I recommend you create an index on the date_time_stamp column, since that will make the above query work far faster. Simon. _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users