mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-10-06 02:17:39 +02:00
Fix networkGeolocationCounts for MySQL
This commit is contained in:
parent
7080b7b3b2
commit
26cd95cab8
@ -182,14 +182,19 @@ public class ServerAggregateQueries {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Query<Map<String, Integer>> networkGeolocationCounts() {
|
public static Query<Map<String, Integer>> networkGeolocationCounts() {
|
||||||
String subQuery = "SELECT " +
|
String subQuery1 = "SELECT " +
|
||||||
GeoInfoTable.USER_UUID + ", " +
|
GeoInfoTable.ID + ", " +
|
||||||
GeoInfoTable.GEOLOCATION + ", " +
|
GeoInfoTable.GEOLOCATION + ", " +
|
||||||
GeoInfoTable.LAST_USED + ", " +
|
GeoInfoTable.LAST_USED + ", " +
|
||||||
|
" FROM " + GeoInfoTable.TABLE_NAME;
|
||||||
|
String subQuery2 = "SELECT " +
|
||||||
|
GeoInfoTable.ID + ", " +
|
||||||
"MAX(" + GeoInfoTable.LAST_USED + ") as m" +
|
"MAX(" + GeoInfoTable.LAST_USED + ") as m" +
|
||||||
" FROM " + GeoInfoTable.TABLE_NAME +
|
" FROM " + GeoInfoTable.TABLE_NAME +
|
||||||
" GROUP BY " + GeoInfoTable.USER_UUID;
|
" GROUP BY " + GeoInfoTable.USER_UUID;
|
||||||
String sql = "SELECT " + GeoInfoTable.GEOLOCATION + ", COUNT(1) as c FROM (" + subQuery + ") AS q1" +
|
String sql = "SELECT " + GeoInfoTable.GEOLOCATION + ", COUNT(1) as c FROM (" +
|
||||||
|
"(" + subQuery1 + ") AS q1" +
|
||||||
|
" INNER JOIN (" + subQuery2 + ") AS q2 ON q1.id = q2.id)" +
|
||||||
" WHERE " + GeoInfoTable.LAST_USED + " = m" +
|
" WHERE " + GeoInfoTable.LAST_USED + " = m" +
|
||||||
" GROUP BY " + GeoInfoTable.GEOLOCATION;
|
" GROUP BY " + GeoInfoTable.GEOLOCATION;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user