Quantcast
Viewing all articles
Browse latest Browse all 75251

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

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

Viewing all articles
Browse latest Browse all 75251

Trending Articles



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