AdvancedSQLFree prompt

Geospatial SQL Analysis: Store Cannibalization and Market Coverage,

Geospatial SQL queries to analyze store coverage, detect cannibalization between locations, and identify underserved markets for expansion.

Use geospatial SQL functions to calculate distances between stores, analyze customer catchment areas, detect revenue cannibalization, and recommend optimal new store locations.

At a glance

Access

Free prompt

Open to copy — no account or payment needed.

Prompt objective

Use geospatial SQL functions to calculate distances between stores, analyze customer catchment areas, detect revenue cannibalization, and recommend optimal new store locations.

Real use case

A retail chain with 85 stores across the country wants to open 15 new locations but needs to ensure new stores don't cannibalize existing ones. They also want to identify markets with high demand but no coverage.

Customize these fields first

COMPANY NAMENUMBER

Replace the placeholders with your own context before you run the prompt. That usually improves the first output more than adding more instructions later.

Prompt

Write geospatial SQL queries for [COMPANY NAME]'s retail network with [NUMBER] stores and [NUMBER] customer records.

Tables:
- `stores` (id, name, lat, lon, city, state, monthly_revenue, open_date, size_sqft)
- `customers` (id, lat, lon, city, state, total_spend, last_purchase, store_id)
- `transactions` (id, customer_id, store_id, amount, date)

**Query 1 — Distance Matrix:**
- Distance between every pair of stores (Haversine formula or ST_Distance)
- Identify stores within [X] km of each other (cannibalization risk)
- For each close pair: combined revenue vs. expected revenue if independent

**Query 2 — Customer Catchment Areas:**
- Assign each customer to nearest store
- Calculate: average distance to store, % of customers within 5km/10km/20km
- Revenue per customer by distance band
- Identify customers traveling >[X] km (potential new store locations)

**Query 3 — Market Coverage Analysis:**
- Population coverage: % of target population within [X] km of a store
- Revenue density: revenue per km² by region
- Underserved areas: high population, low store density
- Over-served areas: multiple stores competing for same customer base

**Query 4 — Cannibalization Impact:**
- When a new store opened, how much did nearby stores' revenue drop?
- Compare revenue trend of stores near new openings vs. isolated stores
- Estimate cannibalization rate: % of new store revenue that came from existing stores

**Query 5 — Optimal Location Recommendation:**
- Score candidate locations by: population density, distance to nearest store, competitor presence, demographic fit
- Rank top [NUMBER] locations for expansion

SQL dialect: PostgreSQL with PostGIS extensions.

Open directly in an AI — the text is pre-filled:

How to use this prompt

  1. 1Replace the key placeholders first: COMPANY NAME, NUMBER.
  2. 2Replace any bracketed placeholders like [this] with your own context.
  3. 3Add extra background information when you want more tailored results.
  4. 4Combine multiple prompts in one conversation when you need a richer output.
  5. 5Save your best-performing prompts so they are easy to reuse later.

Next best step

Open the guide first, then branch only if you still need more.

A guide for technical builders choosing between prompts, coding workflows, and agent-based implementation.

If this prompt is close but not quite right, generate variants next. If the job is recurring, move into the course library after the guide.

Related prompts

View all

Explore other prompt categories

Move sideways into adjacent libraries when the current category is not the full answer.

Every prompt here is free. The course teaches the thinking behind them.

Copy as many prompts as you like. When you want to move from single prompts to a repeatable AI workflow, Learn AI in 30 Days walks through it, one day at a time.

Get the courseSee the 30-day curriculum first

Buy the course once ($15/$20 by length), or go all-access for $10/mo with a verifiable certificate.