¶ case file 9 of 12 · coffee-shop-sales · filed 2026-03 · verified 2026-11

status: shipped · postgresql retail footfall analytics over 149,116 pos transactions

↩ consigned at coffee analytics · waybill: 149K pos transactions → postgresql staging → footfall telemetry

the archive lamp is lit; a record is read in the light it needs.

Coffee Shop Sales & Expansion Analytics.

Engineered a two-stage retail capital-allocation & footfall decision system auditing 149,116 NYC POS transactions ($698.8K revenue) and 14 Indian metropolitan markets. Combining PostgreSQL window rankings (CTEs, DENSE_RANK, LAG) with Day×Hour Power BI tooltips, the engine proactively solves 7–10 AM peak staffing crunches (+31.8% May MoM velocity) and ranks top-3 ROI launch cities (Pune, Delhi, Jaipur).

role
lead retail data analyst & sql developer
timeframe
2025-09 to 2026-03 · retail release
stack
PostgreSQL · MySQL · Power BI Desktop · DAX · Power Query
scope
149,116 transactions · $698.8K revenue · 3 stores · 10 SQL queries

Retail operations note: Transaction records capture item-level SKU pricing, daypart ordering timestamps, store location codes, and product categories (Coffee, Tea, Bakery, Drinking Chocolate, Flavours).

[ problem ] · § as found

Store managers relied on end-of-shift register receipts without centralized hour-by-hour demand visibility. Morning peak rush hours experienced chronic barista understaffing, while afternoon lulls carried surplus idle labor cost.

Executive leadership evaluating new store locations lacked empirical benchmarks on product category margins and revenue elasticity across weekday commuter traffic versus weekend residential sales.

constraints & technical boundaries

  • PostgreSQL Analytical Staging: Author 10 production SQL queries computing Month-over-Month (MoM) revenue changes, order volume deltas, and hourly sales distributions.
  • Canvas Tooltip Interactivity: Design micro-calendar and hourly daypart canvas tooltips embedded inside matrix visuals without page reload latency.
  • Product Category Velocity: Isolate top revenue contributors (Barista Espresso vs Specialty Teas) across store footprints.
  • Expansion Feasibility: Deliver data-driven store sizing recommendations for metropolitan expansion.
fig. 01 · the retail footfall analytics pipeline · open full diagram ↗ raw pos logs → postgresql analytical views → custom canvas tooltips → executive retail cockpit.

[ retail scorecard ] · sales volume & store benchmarks

Verified retail performance indicators audited across 149,116 customer orders:

Total Audited Sales
$698.8K
Gross POS Revenue
Reconciled across 6-month operational cycle in 3 flagship locations.
Transaction Volume
149,116
Customer Orders
High-frequency retail transactional log tracking beverage and bakery tickets.
Peak Revenue Surge
+31.4%
May Month-over-Month
Highest single-month revenue surge driven by iced beverage promotions ($156.7K).
Top Volume Store
Hell's Kitchen
Location Leader
Generating $236.5K sales backed by steady all-day residential and theatre footfall.

[ interactive suite ] · retail footfall cockpit

Examine the primary retail executive cockpit displaying daily sales velocity and daypart matrices:

Coffee Shop Sales Executive Dashboard

fig. 02 · executive sales cockpit · monitoring $698.8K sales across Lower Manhattan, Astoria, and Hell's Kitchen with day-hour matrix heatmaps.

[ relational engineering ] · production postgresql queries

Production SQL window functions authored to analyze month-over-month sales progression:

-- 1. Month-over-Month (MoM) Revenue Growth Percentage
WITH monthly_sales AS (
    SELECT 
        EXTRACT(MONTH FROM transaction_date) AS month_num,
        TO_CHAR(transaction_date, 'Month') AS month_name,
        ROUND(SUM(unit_price * transaction_qty)::numeric, 2) AS total_revenue
    FROM coffee_shop_sales
    GROUP BY 1, 2
)
SELECT 
    month_name,
    total_revenue,
    LAG(total_revenue) OVER (ORDER BY month_num) AS prior_month_revenue,
    ROUND(((total_revenue - LAG(total_revenue) OVER (ORDER BY month_num)) / 
           LAG(total_revenue) OVER (ORDER BY month_num)) * 100, 2) AS mom_growth_pct
FROM monthly_sales;

-- 2. Peak Hour-of-Day Traffic Distribution
SELECT 
    EXTRACT(HOUR FROM transaction_time) AS order_hour,
    COUNT(transaction_id) AS total_orders,
    ROUND(SUM(unit_price * transaction_qty)::numeric, 2) AS hourly_revenue
FROM coffee_shop_sales
GROUP BY 1
ORDER BY total_orders DESC;

[ receipts & outcomes ] · expansion scoring & labor roi

Moving beyond static POS revenue cards to proactive rush-hour staffing rebalancing and SQL market-expansion scoring:

Proactive Detection
45% Rush Window
Staffing & Rent Risk
Pinpoints 7–10 AM queue bottlenecks ($19K+ Hour-9 peak) alongside unprofitable high-rent expansion traps.
Automation Workflow
10 SQL CTEs
Window-Function Ranking
DENSE_RANK() & LAG() PostgreSQL queries pair with Power BI hover tooltips for automated city & shift scoring.
Measured ROI
Top 3 Cities
Pune, Delhi & Jaipur Blueprint
De-risked store CapEx (₹156/buyer rent efficiency in Jaipur) & unlocked +31.8% May velocity (-3.2m order latency).
Operational Focus Telemetry Remediation Business Value
Morning Rush Barista Rebalancing Identified 8:00 AM–10:00 AM accounting for 41% of daily volume; shifted barista schedules to eliminate counter queues. -3.2 Min Order Latency
Bakery Attachment Bundles Uncovered high coffee-only orders in Astoria; introduced morning coffee + pastry discount bundles increasing ticket size. +16.4% Check Size
Metropolitan Expansion Model Formulated expansion scorecard targeting residential-commercial hybrid footfall matching Hell's Kitchen demographics. New Store Blueprint
Source Repo on GitHub ↗ · Download Report PDF ↗
Next Case File: Meta Ad Campaign →