"Expressions in an index may not reference other tables and may not use subqueries nor functions whose result might change"
max(ts_from) not only depends on every other record in the table, but is also subject to change dependant on future inserts. If what you want is a field that contains the highest previously seen ts_from, you will have to use a SELECT to determine the current max(ts_from). -----Ursprüngliche Nachricht----- Von: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im Auftrag von ingo Gesendet: Freitag, 21. Juni 2019 11:29 An: sqlite-users@mailinglists.sqlite.org Betreff: [EXTERNAL] [sqlite] misuse of aggregate function max() CREATE TABLE test( id INTEGER NOT NULL, ts_from TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, ts_eol TEXT DEFAULT NULL ); CREATE UNIQUE INDEX idx_test ON test(id, max(ts_from), ts_eol) WHERE ts_eol = NULL ; --Error: misuse of aggregate function max() Is this because max() is not deterministic, or because current_timestamp is not, or both? Ingo _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org<mailto:sqlite-users@mailinglists.sqlite.org> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users ___________________________________________ Gunter Hick | Software Engineer | Scientific Games International GmbH | Klitschgasse 2-4, A-1130 Vienna | FN 157284 a, HG Wien, DVR: 0430013 | (O) +43 1 80100 - 0 May be privileged. May be confidential. Please delete if not the addressee. _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users