Topic: max/min functions in select statements

Hi,
I am trying to get the latest timestamp for each group in a table using:
SELECT EntryID, max(EntryDate) FROM Entries GROUP BY EntryID;

The query works if I use it in SQLite Database Browser but fails in SQLiteToolbox or when I try to use in a Lazarus program.
When running the program I get an EDatabaseError with message: TSqlitePassSelectStmt.BuildSchema : Table or field not found .

Is there some easy workaround I could do or will I have build a table myself going through each ID and get the latest date?

Re: max/min functions in select statements

The TSqlitePassSelectStmt.BuildSchema retrieves tables names and fields names from the following sqlite functions :
     FieldName := SqliteDbv3_column_origin_name(StmtHandle, i);
     TableName := SqliteDbv3_column_table_name(StmtHandle, i);

I am using these functions because I don't have a built-in sql parser yet (planed for futur versions). The bad news : sometimes, sqlite returns an empty tablename. I think this is what happened with your query.

A possible work around would be to provide the correct table and field names directly in the buildschema function (replacing SqliteDbv3_column_origin_name(StmtHandle, i) with your own function that should return the table name...)

I'm already working on others changes in the TSqlitePassSelectStmt object so I don't think it will be for the next version.

I'm very interested in finding an answer to this problem. That will allow to use the component whithout the need to compile the sqlite library with SQLITE_ENABLE_COLUMN_METADATA.