|
Hello Reader, Almost every business question boils down to one of two things:
How many customers booked this month? How much revenue did we generate? How many trips were cancelled? How much did we lose? Once you're comfortable with COUNT and SUM, you can answer the majority of questions that come your way (like sales analytics using SQL). Let me show you both patterns using a real business scenario. The ScenarioYour operations manager asks: "Give me a breakdown of our bookings and revenue by expedition type. I need to know which categories are driving volume and which are driving dollars." Two questions in one. COUNT answers the first. SUM answers the second. The QueryHere's what I ran against the Summit Adventures database (the fake adventure tourism company I created to help people learn business analytics):
Summit Adventures results look roughly like this:
Photography leads in booking volume but cultural leads in revenue. That means cultural trips have a higher average transaction value (e.g., customers pay more per booking.) This tells the operations team something important: cultural expeditions are premium products, while photography is a volume play. Different strategies for different categories. One query reveals both. COUNT: The Volume FunctionCOUNT answers "how many" questions:
SUM: The Value FunctionSUM answers "how much" questions:
SUM is straightforward, but there's one important thing: Make sure you're filtering correctly before summing. If you SUM all payments without filtering for Using Them TogetherThe real power comes when you combine COUNT and SUM in the same query:
Now you can answer: "Which experience level has the most customers? Which generates the most revenue? Which has the highest value per customer?" These are three different questions from one query.
Two Common MistakesMistake 1: Counting when you should be summing "How much revenue did we make?" โ Use SUM(amount), not COUNT(*) COUNT(amount) tells you how many payment records exist. SUM(amount) tells you how much money came in. Very different answers. Mistake 2: Forgetting DISTINCT If you JOIN customers to bookings to payments, a customer with 3 bookings appears 3 times. When you want "how many unique customers," always use DISTINCT. When you want "how many transactions," regular COUNT is correct. The Pattern to Remember
This three-metric pattern (volume + value + efficiency) answers almost any business performance question. Use it with different category columns โ by region, by product, by time period, by team โ and you've got a flexible analytical tool. Try This At Your JobNext time your manager asks about business performance, structure your answer around these three questions:
"We had 280 cultural bookings (volume) generating over $370K (value), averaging about $1,300 per booking (efficiency)." That's a complete answer from two SQL functions. Until next time, Brian P.S. Understanding when to use COUNT vs SUM is one of those skills that seems simple but makes a massive difference in daily work. Module 6 of SQL for Business Impact goes deep on revenue analysis patterns using these functions and the So What Framework. Check it out at sqlforbusinessimpact.com. P.P.S. What's the most common "how many" or "how much" question you get asked at work? Reply and share it. I might turn it into a future SQL walkthrough. I read every response. |
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.
HeyReader, Most analysts never think to ask: "Why are our customers cancelling?" Everyone looks at bookings. Everyone reports revenue. But the data hiding in your cancelled orders often tells a more important story than your completed ones. And analysts that want to move from beginner to intermediate SQL skill level have an unfair advantage here. Because there's a sequence to work through this kind of problem. That's what we're covering here. At Summit Adventures (the fake adventure tourism...
Hey Reader, Imagine you're a marketing analyst and your marketing director walks over and says: "I need our customers broken into spending tiers (VIP, Standard, and Low Value) so I can send different emails to each group." You have the data. But every customer just has a dollar amount. There's no "tier" column in the database. How do you create categories that don't exist yet? This is where CASE WHEN becomes one of the most useful tools in your SQL toolkit. The problem is that raw data...
Hey Reader, This week's newsletter is different. Not a regular "how to solve problem X with SQL" kinda thing. Because I've realized something: you can write perfect queries and still never get the career impact you want. You need "soft skills" like presenting your results to leadership in addition to "technical skills" like using CTEs and WINDOW functions. Let me show you what I mean. The Scenario Wednesday, 2pm. Q2 review meeting. CMO: "Our booking conversion is down. What's causing it?"...