Is Your SQL Quality Code or a Collection of Bad Practices?

data analyst sql Mar 31, 2024
Photo by Alexander Sinn on Unsplash

I’ve spent over 20 years of my career in tech and the last 12 years as a people leader, building world-class analytics teams and organizations. Throughout my career I’ve held in roles in analytics, software development, software QA, and more. and I’ve had the opportunity to work at Amazon, eBay, VMware, GameStop, and multiple startup companies. While my roles and companies have change, one thing that has always remained the same is that the quality of your code matters. Unfortunately, in the analytics space, quality code seems to be a luxury, not a foundational requirement for analysts.

What is Quality Code?

The quality of your code can be thought of in a few different ways. But the common thought for most people is, “Is the code bug-free?” While this is arguably the most important part of quality, it’s not the only aspect to consider. Another aspect of code quality is around the performance of the code. Even if it’s bug free and it works, your code isn’t necessarily performant. And, if you want to produce performant and bug-free code, your code is going to need to be DRY (don’t repeat yourself –- or anyone else’s code).

But to avoid duplicating code, creating non-performant code, or producing bugs, you need to write and organize your code the proper manner. Your code needs to be readable and understandable; not just for you, but for everyone that will ever touch your code. This is where the conflict begins.

Excuses and More Excuses

Whenever I’ve become involved in discussions about the ease of reading and understanding code, I’ve found that there’s always three groups of people: the people that get excited and want to make their work better, the people that are indifferent and they’ll do it if you ask, and the people that outright resist and make excuses.

Within the group of people that make excuses, I frequently hear the same comments, which include, “It doesn’t matter, I know what the code means”, “Nobody else is going to read my code”, “That’s just nitpicking”, and “I don’t have time for that”. All of these are excuses and couldn’t be further from the truth.

Even if you are the only person that is ever going to work with that code which is highly unlikely, your code quality matters. You can think this article as an example.

Or you could read this content. It’s the same exact content. The difference is how it’s written.

The same is true when working with code, but it’s worse because your job is to find problems in the code or to modify the code, not simply read the code. But efficiently reading and modifying code is extremely challenging when the code lacks consistency or uses bad practice.

With those examples in mind, it would be foolish to think that creating high-quality code would make someone less efficient at reading and understanding their code. We should all create high-quality code. If we can all agree that better formatting and practices is a good thing and the right thing to do, then the only argument against it should be around the cost of writing good code.

But there really isn’t a cost of writing good code. Is there a cost to properly formatting this article? No, it’s just second nature. We spell things correctly, we write with convention, and there are agreed upon items such as chapters, paragraphs, footnotes, and more that help the reader to understand what we’re writing. But it’s not just written documents that follow standard convention and best practices. Almost every other software development language uses fairly strict conventions within the programming community.

If you’re writing Ruby code, you know that you use one line per expression.

And you use spaces between operators.

When it comes to SQL code, many people do not pay attention to proper convention. I blame the lack of true teamwork, which frequently comes with code reviews and oversite. I also blame the lack of training so that people learn and value proper convention from day one. But for the change-resistant people that are made aware of a different way of working I find that they frequently argue is that their code is good enough, and any modifications are unnecessary.

Granted, this is usually an argument without any actual objectivity, just like someone arguing that the “bad” examples in the Ruby code above are not bad. Then when presented within valid arguments for proper convention, the next objection is usually how the convention is wrong or worse, how “everyone else does it this way”, which is a cop-out for constantly seeking to find a better way of working. It doesn’t matter if everyone in the organization is doing something one specific way or if all that someone has ever seen in their few examples is one specific way of working. Just because people are following a bad practice doesn’t mean it’s the right practice.

Why do I share this? Because creating better code that allows for fewer bugs and more efficient reading and editing starts with having awareness of the problem. And once you have awareness that poor code practices exist, you can determine which group of people you are in. You can choose to be with those who want to make things better or those who resist and think they are good enough already. From there, it’s up to you to take the time to understand the best practices, not the common practices, and implement better ways of working with your SQL code. 


Brandon Southern, MBA, is a highly accomplished business professional and the founder of Analytics Mentor. With a remarkable 20-year career in the tech industry, Brandon has excelled in diverse roles encompassing analytics, software development, project management, and more. His expertise has been sought after by esteemed companies such as GameStop, VMWare, eBay, and Amazon.

Renowned for his ability to build world-class analytics organizations, Brandon has generated over $100 million in revenue and savings. His strategic insights and leadership have transformed businesses, delivering exceptional results. With a passion for empowering individuals and fostering growth, Brandon is dedicated to elevating the analytics landscape and driving success.

You can learn more about Brandon and Analytics Mentor at

Subscribe to Receive New Articles

Join our mailing list to receive the latest articles and tips to elevate your career.

We hate SPAM. We will never sell your information, for any reason.