Tony CantaveFive SQL Queries That Answer Real Small Business Questions
By Tony Cantave ·
When people hear SQL, they picture a database team in a big office. In my experience it is one of the most useful tools a small business owner or a solo developer can learn, because most business questions come down to the same few moves: filter, group, count, add up and sort. I spent years as a production manager working with ERP and SAP systems, where reports pulled from data drove daily decisions, and SQL is still one of the skills I use most as a developer. Here are five queries I come back to again and again, written against a simple example table so you can follow along.
The example table
Imagine a table called sales with one row per sale. It has these columns: sale_id, customer_name, product, category, amount, sale_year and sale_month. You can build this in SQLite in a few minutes, or export a spreadsheet from your point of sale system and load it. The data you practice on can be made up. The queries work the same way on real records.
1. How much did we sell this month?
SELECT SUM(amount) AS total_sales
FROM sales
WHERE sale_year = 2026 AND sale_month = 10;This is the simplest useful query there is. WHERE picks the rows you care about, and SUM adds up one column. Change the month and you have a quick comparison with last month. I like to run this first whenever I look at new data, because if the total looks wrong, something is off with the data itself and every other answer will be wrong too.
2. Which products bring in the most money?
SELECT product, SUM(amount) AS revenue, COUNT(*) AS orders
FROM sales
GROUP BY product
ORDER BY revenue DESC
LIMIT 10;GROUP BY is where SQL starts to feel like a superpower. Instead of one total, you get one total per product. Adding COUNT next to SUM tells you whether a product earns its spot through many small sales or a few big ones. Those are very different stories, and they lead to very different decisions about what to promote.
3. Who are my repeat customers?
SELECT customer_name, COUNT(*) AS visits, SUM(amount) AS total_spent
FROM sales
GROUP BY customer_name
HAVING COUNT(*) >= 3
ORDER BY total_spent DESC;HAVING is like WHERE, but it filters after grouping. Here it keeps only customers with three or more purchases. For a barbershop, a laundromat or a small shop, this list is gold. These are the people worth thanking, the people most likely to tell a friend, and the first people to hear about something new.
4. How does each category trend month to month?
SELECT category, sale_month, SUM(amount) AS revenue
FROM sales
WHERE sale_year = 2026
GROUP BY category, sale_month
ORDER BY category, sale_month;Grouping by two columns gives you a small table you can paste into a spreadsheet and chart. One line per category, one point per month. Seasonal patterns jump out right away. If one category always dips in the same month, that is when to plan a promotion instead of being surprised by it.
5. Are there records that should not be there?
SELECT *
FROM sales
WHERE amount <= 0
OR customer_name IS NULL
OR product IS NULL;This one is about trust. Before I believe any report, I look for rows that break the rules: zero or negative amounts, missing names, missing products. Sometimes they are refunds that belong somewhere else. Sometimes they are typos. Either way, finding them early saves you from making a decision on bad numbers. Manufacturing taught me that habit, because in a production system one bad record can quietly throw off everything that depends on it.
A few habits that make SQL easier
Write queries in the same order every time: SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY. It makes them easier to read later. Give every calculated column a clear name with AS, so the output explains itself. Start small, check the result, then add one piece at a time. When a query gets long, I build it the same way I debug Python: change one thing, run it, look at the result.
Also, keep a text file of queries that worked. Most business questions repeat. Next month you will want the same answer for a different month, and having the query saved turns a twenty minute job into a twenty second one.
Why this matters
Most small businesses already have the data to answer these questions sitting in a point of sale export or a spreadsheet. What they usually lack is a fast way to ask. SQL is that way. You do not need to become a database administrator. Learn these five patterns, practice them on a copy of your own data, and you will start seeing your business in numbers instead of guesses.
If you run a Connecticut small business and want to talk about turning your data into decisions, or about getting in front of local customers, you can reach me at sales@localflyerads.com.