> -- if endtime is in a different position in the table, the query works > CREATE TABLE interval (endtime INTEGER, entryid INTEGER, starttime INTEGER); > CREATE TABLE entry (id INTEGER PRIMARY KEY AUTOINCREMENT); > > INSERT INTO entry (id) VALUES ( 42); > > INSERT INTO interval (endtime, entryid, starttime) VALUES (2, 42, 1); > -- if the endtime below is greater than or equal to the endtime above, > the query works > INSERT INTO interval (endtime, entryid, starttime) VALUES (1, 42, 3); > -- if endtime is removed from the projection, the query works > -- if the LEFT JOIN is changed to INNER JOIN, the query works
> SELECT starttime, endtime from entry LEFT JOIN interval ON > interval.entryid = entry.id GROUP BY entry.id HAVING starttime = > MAX(starttime); Strictly speaking, the result of the HAVING expression is undefined here. As "starttime" is not an aggregate or a part of the GROUP BY clause. Dan. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users