This is a common misunderstanding with SQL. The aggregate functions such as Max() don't return a full row, just the single variable they are applied to. What the SQL then returns for the other entries in the row is undefined. You might find that it worked for you today on that database but it likely won't tomorrow, or after the database has been changed, or in other versions or dialects of SQL. In fact you've just proved that by trying two different instances of SQLite, one in GSAK and another in the manager, that give differing results. Image may be NSFW.
Clik here to view.
(If you google SQL and aggregate matching row, you'll find this discussed many times)
The query as initially written is undefined by the SQL language standard so will return undefined results. Insisting that the incorrect SQL must be good because it happened to give you the correct answer once doesn't change the fundamental problem. If you use the code suggested, which is fully defined, then you should get the same answer in all versions and all dialects.
Clik here to view.

(If you google SQL and aggregate matching row, you'll find this discussed many times)
The query as initially written is undefined by the SQL language standard so will return undefined results. Insisting that the incorrect SQL must be good because it happened to give you the correct answer once doesn't change the fundamental problem. If you use the code suggested, which is fully defined, then you should get the same answer in all versions and all dialects.