The following query gets me a distance column. But I only need to count the results with the corresponding distances, not the distances themselves. The subrecord cannot be used.
SELECT ( 6368 * SQRT(2*(1-cos(RADIANS(loc_lat)) * cos(0.899945742869) * (sin(RADIANS(`loc_lon`)) * sin(0.14286767838) + cos(RADIANS(`loc_lon`)) * cos(0.14286767838)) - sin(RADIANS(loc_lat)) * sin(0.899945742869))) ) AS Distance FROM ... WHERE ... HAVING Distance > 0 AND Distance <= 25
source share