It's just luck that the SQLite Manager version appears to give the right answers, it quite likely doesn't!
The problem, as Lil Devil said, is that the Max() only returns the Max() data for its own field, it does *not* return the matching data for the other field from the same rows, they could be any values. Image may be NSFW.
Clik here to view.
This is a very common problem for SQLite. How do I get the data for the row that has some some max (or min) value in one of its columns?
You have to use INNER JOINS to do it, first work out the max() value for each letter, then use that as a joined table to find the matching row in the main table. Try this:
The problem, as Lil Devil said, is that the Max() only returns the Max() data for its own field, it does *not* return the matching data for the other field from the same rows, they could be any values. Image may be NSFW.
Clik here to view.

You have to use INNER JOINS to do it, first work out the max() value for each letter, then use that as a joined table to find the matching row in the main table. Try this:
SQL |
select upper(substr(a.name,1,1)) as letter, a.code, a.name, (a.difficulty+a.terrain) as points from caches as a inner join (select upper(substr(name,1,1)) || max(difficulty+terrain) as combo from caches where cachetype='U' and found='1' group by upper(substr(name,1,1))) as b on letter || points = combo where cachetype='U' and found='1' group by upper(substr(name,1,1)) |