🟒 The SQL Queries That Work in Every Industry (With Examples)


Hey Reader -- I'm trying something new this week! Can you take a minute to fill out this quick survey? Thanks in advance!

Okay, on to this week's topic:

​

A common question I get from readers is some version of:

"This Summit Adventures stuff is great, but I work in healthcare (or SaaS, or retail, or finance). How does this apply to me?"

The honest answer: every SQL pattern you've learned in this newsletter translates directly to your industry. The table names change. So do column names. The business questions are a bit different. But the SQL is the same. That's what's so cool about learning SQL!

Let me show you exactly what I mean.

Three Core SQL Patterns (And Exactly Where They Apply)

Recently, I've REALLY doubled-down on writing every single week about one topic: SQL.

And we've covered patterns that solve universal business problems:

Today, I'm going to break down how these universal SQL concepts translate across healthcare, SaaS, retail, and finance:

Pattern 1: Customer Segmentation (CASE WHEN + GROUP BY)

Summit Adventures version: Identify customer segments by total spend

CASE 
    WHEN total_spent >= 10000 THEN 'VIP'
    WHEN total_spent >= 5000 THEN 'High Value'
    ...
END

Healthcare: "Which patients need proactive outreach from care management?"

-- Patient risk segmentation
CASE 
    WHEN visit_count >= 12 AND has_chronic_condition = TRUE 
        THEN 'High Risk - Frequent'
    WHEN has_chronic_condition = TRUE 
        THEN 'Managed Chronic'
    WHEN visit_count >= 4 
        THEN 'Active Patient'
    ELSE 'Low Utilization'
END AS patient_segment

SaaS: "Which users should Customer Success prioritize for retention outreach?"

-- User engagement tiers
CASE 
    WHEN logins_last_30d >= 20 AND features_used >= 5 
        THEN 'Power User'
    WHEN logins_last_30d >= 5 
        THEN 'Active'
    WHEN logins_last_30d >= 1 
        THEN 'At Risk'
    ELSE 'Churned'
END AS engagement_tier

Retail: "Where should we focus our holiday marketing campaign?"

-- Purchase frequency segments
CASE 
    WHEN orders_last_90d >= 5 THEN 'Loyal Repeat Buyer'
    WHEN orders_last_90d >= 2 THEN 'Occasional Buyer'
    WHEN orders_last_year >= 1 THEN 'Lapsed Buyer'
    ELSE 'Prospect'
END AS buyer_segment

Pattern 2: What's Missing (LEFT JOIN + IS NULL)

Summit Adventures version:

-- Customers who never booked
FROM customers c
    LEFT JOIN bookings b ON c.customer_id = b.customer_id
WHERE b.booking_id IS NULL

Healthcare: "Which patients are overdue for preventive care?"

-- Patients due for annual wellness visit who haven't scheduled
FROM patients p
    LEFT JOIN appointments a ON p.patient_id = a.patient_id
        AND a.appointment_type = 'annual_wellness'
        AND a.appointment_date >= CURRENT_DATE - INTERVAL '1 year'
WHERE a.appointment_id IS NULL

SaaS: "Which paying customers haven't discovered our most valuable feature?"

-- Paying customers who haven't used a key feature
FROM subscriptions s
    INNER JOIN users u ON s.user_id = u.user_id
    LEFT JOIN feature_usage fu ON u.user_id = fu.user_id
        AND fu.feature_name = 'reporting_dashboard'
WHERE fu.usage_id IS NULL
    AND s.status = 'active'

Finance: "Which accounts are dormant and at risk of closing?"

-- Accounts with no transactions in 90 days
FROM accounts a
    LEFT JOIN transactions t ON a.account_id = t.account_id
        AND t.transaction_date >= CURRENT_DATE - INTERVAL '90 days'
WHERE t.transaction_id IS NULL
    AND a.status = 'active'

Pattern 3: Trend Analysis (GROUP BY + date functions)

Summit Adventures version:

-- Monthly revenue trends
SELECT TO_CHAR(booking_date, 'YYYY-MM'), SUM(amount)
GROUP BY TO_CHAR(booking_date, 'YYYY-MM')

Healthcare: "How many patients are we getting in each department by month?"

-- Monthly patient volume by department
SELECT 
    department,
    TO_CHAR(visit_date, 'YYYY-MM') AS month,
    COUNT(DISTINCT patient_id) AS unique_patients,
    COUNT(*) AS total_visits
FROM visits
GROUP BY department, TO_CHAR(visit_date, 'YYYY-MM')
ORDER BY department, month

SaaS: "What's our monthly recurring revenue trend?"

-- Monthly recurring revenue (MRR) trend
SELECT 
    TO_CHAR(billing_date, 'YYYY-MM') AS month,
    COUNT(DISTINCT subscription_id) AS active_subs,
    SUM(monthly_amount) AS mrr
FROM billing_events
WHERE status = 'paid'
GROUP BY TO_CHAR(billing_date, 'YYYY-MM')
ORDER BY month

Retail: "What is the sales volume trend across stores?"

-- Same-store sales comparison
SELECT 
    store_id,
    TO_CHAR(sale_date, 'YYYY-MM') AS month,
    SUM(sale_amount) AS monthly_revenue,
    COUNT(DISTINCT transaction_id) AS transactions
FROM sales
GROUP BY store_id, TO_CHAR(sale_date, 'YYYY-MM')
ORDER BY store_id, month

The Translation Formula

Here's the mental model:

Summit Adventures Your Industry Equivalent
customers patients, users, accounts, members
bookings appointments, orders, transactions, subscriptions
expeditions services, products, plans, programs
payments claims, invoices, billing_events, transactions
guides providers, agents, representatives, employees
booking_date visit_date, order_date, transaction_date
status = 'cancelled' status = 'churned', 'no-show', 'returned'

The SQL structure stays identical. Just swap out the nouns.

The Frameworks We've been Covering Are Universal

This is something I want to emphasize. The 8 frameworks in SQL for Business Impact aren't SQL-specific. They teach you how to *think* like a business analyst using real world principles.

  • The Marie Kondo Blueprint β†’ "Which categories matter for this decision?" works whether you're organizing booking types, patient diagnoses, or product SKUs
  • The Empty Stadium Blueprint β†’ "Who's missing and why?" applies to no-show patients, churned subscribers, and dormant accounts
  • The So What Framework β†’ "What should we do about this number?" is relevant in every industry, every meeting, every report

The specific queries change but how you think doesn't change.

These same analytical patterns translate directly to other tools too. The customer segmentation you build in SQL is the same logic you'd implement in a Python pandas script or a Tableau calculated field.

How to Build Your Industry Translation

If you want to apply these newsletter patterns to your specific job, here's a process:

  • Step 1: Take any query from a previous newsletter
  • Step 2: Replace table names with your company's equivalents
  • Step 3: Replace column names with your actual fields
  • Step 4: Adjust the business question to match your stakeholder's ask
  • Step 5: Adjust thresholds (CASE WHEN values) based on your data's scale

That's it. The SQL patterns are portable. The business context is what makes them valuable in your specific role.

Try It On Your Own

Pick the most common business question you get asked at work. Then:

  1. Identify which newsletter pattern addresses it (segmentation, what's missing, trends, comparisons)
  2. Map your tables and columns to the query structure
  3. Run the query on your own data
  4. Present the results using the So What Framework

You'll be surprised how directly these patterns apply.

Until next time,

Brian

Brian Graves, creator of Analytics in Action

Say πŸ‘‹ on X/Twitter, LinkedIn, or book a call with me. You can always reply to these emails. I check them all.

​

P.S. SQL for Business Impact includes an Industry Translation Guide as a bonus. It maps every course framework to healthcare, retail, SaaS, supply chain, and finance with ready-to-adapt queries. If you want the complete translation toolkit, check it out at sqlforbusinessimpact.com.

P.P.S. What industry are you in, and what's the business question you'd most like to answer with SQL? Hit reply and tell me. I might feature your industry in a future deep dive. I read every response.

P.P.P.S. Quick survey. I'm curious what tool you'd most like to learn next. If you haven't answered yet, there's a one-question poll at the top of this email. Your answer helps me build exactly what you need.

Starting With Data

Learn to build analytics projects with SQL, Tableau, Excel, and Python. For data analysts looking to level up their career and complete beginners looking to get started. No fluff. No theory. Just step-by-step tutorials anyone can follow.

Read more from Starting With Data

Hello Reader, Imagine you're a business analyst at Summit Adventures (the fake adventure tourism company I created to teach real-world business analytics concepts). Your CEO asks a common question: "Who are our best customers?" If you pull a list sorted by total spend, you'll get a spreadsheet with hundreds of rows. Not useful because no one acts on a list of 500 customers. And certainly not the CEO. What they actually need are segments: 3-5 groups with clear labels, clear revenue impact, and...

Hello Reader, Here's a scenario that happens more often than anyone admits: You build a report. Your director uses it in a board presentation. A week later, someone notices the customer count includes 58 records with obviously fake email addresses like evan.clarke743@noemail. The report wasn't wrong. The data underneath it was dirty. And now your credibility takes a hit. Bummer. Not because of your SQL skills, but because you didn't check the final product before sending it off. Data quality...

Hey Reader, Last month, we covered LEFT JOIN to find customers who never booked. That's one type of absence β€” people who never showed up. But there's another kind that's even more expensive: people who showed up, committed, and then left. The dreaded cancellation. Customers who said "yes", then said "actually, never mind". In the Summit Adventures database (the fake adventure tourism company I created to help people learn business analytics), nearly 47% of all bookings end in cancellation....