Geospatial SQL Analysis: Store Cannibalization and Market Coverage,\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n
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 without upgrading.
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
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.\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\nTables:\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n- \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\`stores\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\` (id, name, lat, lon, city, state, monthly_revenue, open_date, size_sqft)\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n- \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\`customers\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\` (id, lat, lon, city, state, total_spend, last_purchase, store_id)\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n- \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\`transactions\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\` (id, customer_id, store_id, amount, date)\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n**Query 1 — Distance Matrix:**\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n- Distance between every pair of stores (Haversine formula or ST_Distance)\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n- Identify stores within [X] km of each other (cannibalization risk)\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n- For each close pair: combined revenue vs. expected revenue if independent\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n**Query 2 — Customer Catchment Areas:**\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n- Assign each customer to nearest store\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n- Calculate: average distance to store, % of customers within 5km/10km/20km\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n- Revenue per customer by distance band\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n- Identify customers traveling >[X] km (potential new store locations)\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n**Query 3 — Market Coverage Analysis:**\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n- Population coverage: % of target population within [X] km of a store\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n- Revenue density: revenue per km² by region\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n- Underserved areas: high population, low store density\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n- Over-served areas: multiple stores competing for same customer base\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n**Query 4 — Cannibalization Impact:**\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n- When a new store opened, how much did nearby stores' revenue drop?\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n- Compare revenue trend of stores near new openings vs. isolated stores\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n- Estimate cannibalization rate: % of new store revenue that came from existing stores\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n**Query 5 — Optimal Location Recommendation:**\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n- Score candidate locations by: population density, distance to nearest store, competitor presence, demographic fit\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n- Rank top [NUMBER] locations for expansion\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\nSQL dialect: PostgreSQL with PostGIS extensions.
Open directly in an AI — the text is pre-filled:
How to use this prompt
- 1Replace the key placeholders first: COMPANY NAME, NUMBER.
- 2Replace any bracketed placeholders like [this] with your own context.
- 3Add extra background information when you want more tailored results.
- 4Combine multiple prompts in one conversation when you need a richer output.
- 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 allSales analysis queries with CTEs and window functions
Writes advanced SQL queries using CTEs and window functions for sales performance analysis.
Best for
Create a set of reusable SQL queries that analyze sales by period, product, seller, and region using CTEs (Common Table Expressions) and window functions for rankings and comparisons.
Database Schema Design for Recurring Subscription Systems
Designs an optimized database schema for a subscription business with SaaS metrics.
Best for
Create a complete relational model for a recurring subscription system, including tables, indexes, constraints, and ready-to-use queries for calculating MRR, churn, and LTV.
Slow Query Optimization with EXPLAIN ANALYZE and Indexes
Diagnoses and optimizes slow SQL queries using execution plans, strategic indexes, and query rewriting.
Best for
Learn to identify SQL query performance bottlenecks using EXPLAIN ANALYZE, create efficient indexes, and rewrite queries to reduce response time.
Stored Procedures for Automatic Sales Commission Calculation
Creates stored procedures that automate commission calculations with complex tiered rules and bonuses.
Best for
Develop SQL stored procedures that calculate sales commissions considering tiered quotas, product mix bonuses, cancellation clawbacks, and team splits.
Explore other prompt categories
Move sideways into adjacent libraries when the current category is not the full answer.
Free browsing stays open. Premium prompts unlock the reusable workflow layer.
Use the guides and role paths to validate the job first. Upgrade when you want the full prompt text, editable premium prompts, and the surrounding course paths in one place.
Free access
- Browse guides, role paths, and category pages.
- Preview prompts before you decide to upgrade.
- Find the right starting point without friction.
Membership access
- Unlock premium prompts and the full copy text.
- See more workflow paths and course connections.
- Keep the reusable templates in one place.