|
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.
Quick note: Before you read this week's newsletter, can you fill out this 5-minute subscriber survey so I know what you want to know more about? I've got a mix of SQL and AI & Agentic Analytics right now. Thanks in advance! Hello Reader, A manager sends you a database login and says, "Can you pull a few customer insights before Friday." You connect to the database and you pause: Because, as a business analyst, there are two ways to respond: Panic and start feverishly writing the SQL, joining...
Hello Reader, This week's newsletter is different. No SQL code. No database queries. I lead a team of 30 data professionals, and we use tools like Claude and Copilot to get oriented, draft, review, and explain routine analysis. The useful part is moving faster without handing over the judgment your team relies on. We call this "human in the loop". Agentic Analytics means using AI as part of your analytical process: give it context, check its work, and keep responsibility for the decision. I...
Hello Reader, Real quick: if you haven't completed this subscriber survey -- now's your chance. Most people are looking to learn more about Agentic Analytics and AI topics. I want to build something that would be useful to you, based on the work I've been doing for the past year or so. Interested? Take 5 minutes to let me know what's on your mind. Take the 5-Minute Survey Now 👉 Imagine it's your first week at a new job. Someone from IT sends over database credentials and a two-line email:...