Guest User

Untitled

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