select a.pop, a.x, a.y, a.village,a.player, distance, sum(a.pop) as total from x_world AS a join (select distinct b.player, SQRT(POW(b.x-73,2)+POW(b.y-5,2)) AS distance from x_world b order by distance asc limit 200) AS c on a.player = c.player group by a.pop order by distance, a.player;