greatest-n-per-group

Replace mysql->php->mysql with nested query

Hello all, I have a table with columns 'customer' and 'location' and I need to check top 10 locations visited by unique customers. I'm ready to do the following: SELECT location FROM myTable GROUP BY location load results to an array (maybe a hundred of few hundreds of locations) SELECT COUNT(*) AS total, tbl.location AS LOCATION FROM...

How to use selects in join clauses in Android 2.1?

I have a query that does some magical sort-group-joining that works just fine on Android 2.2 (froyo) version of SQLite: SELECT channels.*, p.* FROM channels LEFT JOIN programs p ON channels._id = p.channel_id JOIN (select p2.channel_id, max(p2.airdate) max_air FROM programs p2 GROUP BY p2.channel_id) pj ON pj.channel_id = p.chan...