|
Hello Reader, Here's a fact of analyst life: most of the people who use your analysis will never use SQL. Instead, they'll use spreadsheets and reports. Your director doesn't open pgAdmin. Your marketing team doesn't "connect to the database". They open the Excel file or Google Sheet you sent them. And if the data you exported requires 20 minutes of cleanup before it's usable (reformatting dates, splitting columns, fixing number formats) you've done extra work that didn't need to happen. You're really just putting MORE work on their plate, making it way harder than it needs to be. The good news: you can format your query output so it's already clean when it lands in a spreadsheet. A few SQL tricks save significant cleanup time. Raw SQL Output (Lazy) vs. What Executives Actually WantHere's typical raw output from a revenue analysis:
Now have a look at this version:
Same data. But notice the difference in the improved version:
10 minutes of extra effort goes a LONG way! BTW, if you are interested in using Excel more effectively in your business analytics work, check these out:
How to Add Spreadsheet-Ready Formatting to your SQL QueriesHere's a good example of how this can be done quickly and easily using the Summit Adventures database (the fake adventure tourism company I created to help people learn business analytics):
And the results:
4 SQL Functions that Make This WorkHere are the functions that make this work: 1. INITCAP: Capitalize First Letters
2. TO_CHAR: Number Formatting
3. Dollar Signs and Percent Signs
4. Column Aliases With Quotes
Three Export-Ready Query TemplatesTemplate 1: Monthly Summary Report Notice the
Template 2: Customer List for Marketing Dates formatted as "Mar 15, 2025" instead of "2025-03-15". COALESCE handles never-booked customers. Ready for a mail merge!
Template 3: Variance Report Status indicators make the spreadsheet scannable without conditional formatting.
Balancing Formatting in SQL vs. SpreadsheetThere are two rules to keep in mind when formatting in SQL. You have to be careful not to overdo it. Format in SQL when:
Format in the spreadsheet when:
A good rule of thumb: if someone will use your output as-is, format it in SQL. If they'll do further analysis on it, export clean numbers and let them format. Once you can write the query and format the export, the next step is automating that export. That's where tools like Python scripts become your multiplier, running the query, formatting the output, and emailing the spreadsheet automatically. But that's a topic for another day. Try This TodayTake your most common query and add three formatting improvements:
The first time your colleague opens the export and says "this is perfect, I don't need to change anything" -- that's the goal. Until next time, Brian P.S. Presenting data for business impact is a key theme throughout SQL for Business Impact. Whether it's formatting exports or framing insights for executives, the course teaches you the full workflow from query to decision. Check it out at sqlforbusinessimpact.com. P.P.S. What's your least favorite part of the SQL-to-spreadsheet workflow? Hit reply and let me know! I might build a solution for it. 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.
Hello Reader, A while back, I shared some tips about formatting SQL output for spreadsheets. Today we're going the other direction. Doing the kind of analysis that makes spreadsheet formulas feel clunky. Here's the kind of request that analysts get every single day: "Show me monthly revenue and how the trend is moving." If you pull monthly revenue into a spreadsheet, you'd probably create a running total column, then a 3-month moving average column, then a month-over-month change column....
Hello Reader, Most analysts panic when they get a note like this on a random Tuesday afternoon (from the CEO): "Revenue feels off this quarter. Can you figure out what's happening before the board call at 4:30?" Great. You have 90 minutes. No time to build a comprehensive analysis. No time to make it pretty. You need to diagnose the problem (super fast) and deliver a clear answer. Lucky you. You're going to learn the way a seasoned pro handles this situation. I call it The Gordon Ramsay...
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...