On 12/4/08, Brad Stiles <[EMAIL PROTECTED]> wrote: > > SELECT * > > FROM MyTableWithDates > > WHERE datetime("now") > MAX(dtEndDate) > > > What is it that you are actually trying to do with this query? As > formulated (even if it were syntactically correct, which I don't think > it is), you are either going to get every row in the table, or no rows > at all. Since the current date ("now") is either greater than the > maximum date in the table, or it is not, and you're not comparing to a > column in each row, only the aggregate, the resulting condition will > either be true for every row in the table, or false for every row. > > > Brad
As Brad said, your query doesn't make much sense as is, but you can still do it like so -- [10:15 PM] ~/Sites$sqlite3 SQLite version 3.5.9 Enter ".help" for instructions sqlite> create table foo (a); sqlite> insert into foo values ('2008-12-01'); sqlite> insert into foo values ('2008-12-02'); sqlite> insert into foo values ('2008-12-03'); sqlite> select * from foo; 2008-12-01 2008-12-02 2008-12-03 sqlite> select max(a) from foo; 2008-12-03 sqlite> select min(a) from foo; 2008-12-01 sqlite> select * from foo where date('now') > (select max(a) from foo); 2008-12-01 2008-12-02 2008-12-03 sqlite> select * from foo where date('now') < (select max(a) from foo); sqlite> -- Puneet Kishor http://www.punkish.org/ Nelson Institute for Environmental Studies http://www.nelson.wisc.edu/ Open Source Geospatial Foundation (OSGeo) http://www.osgeo.org/ _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users