Guest User

Untitled

a guest
Oct 18th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. SELECT
  2. b.username, b.country, b.region, b.city, b.lat, b.lng, max(count)
  3. FROM (
  4. SELECT
  5. a.username,
  6. a.country,
  7. a.region,
  8. a.city,
  9. a.lat,
  10. a.lng,
  11. count(1) AS count
  12. FROM (
  13. SELECT
  14. username AS username,
  15. geoip(end_song_cleaned.ip_addr, "COUNTRY_CODE", "GeoIPCity.dat") AS country,
  16. geoip(end_song_cleaned.ip_addr, "REGION", "GeoIPCity.dat") AS region,
  17. geoip(end_song_cleaned.ip_addr, "CITY", "GeoIPCity.dat") AS city,
  18. geoip(end_song_cleaned.ip_addr, "LATITUDE", "GeoIPCity.dat") AS lat,
  19. geoip(end_song_cleaned.ip_addr, "LONGITUDE", "GeoIPCity.dat") AS lng
  20. FROM end_song_cleaned
  21. WHERE dt = 20101201
  22. ) a
  23.  
  24. GROUP BY a.username, a.country, a.region, a.city, a.lat, a.lng
  25. ORDER BY username, count DESC
  26. ) b
  27. GROUP BY
  28. b.username, b.country, b.region, b.city, b.lat, b.lng
Add Comment
Please, Sign In to add comment