SELECT DISTINCT date_time_stamp FROM general ORDER BY date_time_stamp DESC
LIMIT 2

isn't it simply to use DISTINCT?

On Mon, Jul 11, 2016 at 4:25 PM, 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
>
>
> Is there a way to store the number of values in the date_time_stamp
> column and use the count minus N to get the largest N values in the
> column?
>
>
> Query:
> select date_time_stamp a from general, c as count(a) from general
> where date_time_stamp!='date_time_stamp_isempty' order by a limit c,2;
>
>
> Error: incomplete SQL: select date_time_stamp a from general, c as
> count(a) from general where date_time_stamp!='_isempty' order by a
> limit c,2
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to