My table setup.
--------------------------
lat (float)
lon (float)
location (varchar)
GeoLocation (geography)
The GeoLocation column above is set as:
----------------------------------------
SET [GeoLocation] = geography::STPointFromText('POINT(' + CAST([lon] AS VARCHAR(20)) + ' ' + CAST([lat] AS VARCHAR(20)) + ')', 4326)
---------------------
My Current Query:
---------------------
SELECT * FROM TheTablename WHERE (lat BETWEEN 40.03497548644043 AND 43.78596734966379) AND (lon BETWEEN -74.2606614248359 AND -70.7450364248359)
Returns all records within the boundries of the Lat and Lon. Works great.
-------------------------------------
What I need to figure out is:
-------------------------------------
How do I modify the above query to get 1 record per 20 mile radius. It would be a plus if I could get the center Lat,Lon of that radius.
For example: If I run the above query, 1 get 500 records back. I want to group them on the SQL server by 1 record per 20 mile radius. I would think it is possible to do this with the GeoLocation column but I just don't know how.
Any help is appreciated.
Thanks