Florian Schricker <fschric...@gmail.com> wrote: > select OPER, PRODUCT, CATEGORY, NAME, [...], VALUE, TEXT, > max(CREATETS) as CREATETS > from table > where oper = 'myOper' and product = 'myProduct' and Category = > 'myCategory' group by OPER, PRODUCT, CATEGOY, NAME order by CREATETS > desc > > which is working fine (and thank you Jeffrey Hoover for that.)
There is no guarantee in this statement that VALUE and TEXT come from the same row from which max(CREATETS) comes. Since these fields don't appear in GROUP BY clause nor as arguments to aggregate functions, they come from some random arbitrary row in the group. Many other database systems will actually reject this statement as syntactically invalid. If this statement appears to work, it's purely by accident, and/or by relying on internal implementation details. In particular, the ORDER BY clause is there to trick SQLite into executing the statement in a certain way that makes the desired outcome more likely, and thus masks the non-deterministic nature of the query. Igor Tandetnik _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users