I'm trying to use CartoDB to Count all of the records a given distance from a selected location.
I have the lat/long for the selected location (call this a store). Now I need to find all of the records (representing customers) that are a given distance (say, 8046 meters/5 miles) from the selected location.
What SQL query should I be using? I've tried some basic things like this, but they didn't work:
'SELECT COUNT() from my_table_name WHERE the_geom && ST_SetSRID(ST_Point(39.8282, -98.5795), 8046)'
SELECT COUNT() from my_table_name WHERE ST_INTERSECTS(the_geom,CIRCLE(LATLNG(39.8282, -98.5795),8046))
What query do I actually need? All I want to do is count the records that meet this criteria. Step 2 would be to filter the points on the map to show only those that meet the criteria, but one thing at a time.