Advanced Reporting

Geospatial Queries with PostGIS

Senior Data Analyst
April 2, 2026
5 min read

The Use Case

Find all stores within 10km of a user's location.

PostGIS Query

SELECT name FROM stores

WHERE ST_DWithin(

geom,

ST_MakePoint(-73.99, 40.73)::geography,

10000 -- 10km in meters

);

Pro Tip

PostGIS is an extension. Enable it with `CREATE EXTENSION postgis;`.

*Day 93: Scheduling SQL Jobs.*

Ready to put your knowledge into practice?

Join SQL Mastery and learn through interactive exercises.