Quantcast
Channel: GSAK Forum
Viewing all articles
Browse latest Browse all 75108

Sqlite manager results. by nottins - 2013-11-30

$
0
0
QUOTE (lignumaqua @ December 01, 2013 02:30 am)
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. blink.gif 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:

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))

Why does the SQL display the correct results in SQLite outside of GSAK ?

Viewing all articles
Browse latest Browse all 75108

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>