A comprehensive SQL style guide

I love neatly placed code! What I mean by neat is, everything is aligned. The comments are not long paragraphs and everything is just in order.

When I first started the SQL course on the Data Analyst path, I was not sure of how to really align SQL queries. Later, I was introduced to the River style on another SQL analysis course (Learn data science with Python and R projects). I’ve used it on a project since. But even while using it, I have often had doubts on how I should set up the names on my tables or whether I should have a space after a comma or whether a subquery should have gone in to a newline and if in a newline how far in to the newline should it be placed etc.

Recently, while reviewing a fellow DQer’s project, I came across this very comprehensive style guide. The highlight of this guide is that it includes examples of good and bad practices.

I must admit that of the many points it mentions, the one I disagree with is the SHOUTCASED SQL. I learned SQL with it, so I find it really useful. Newer learners could avoid it.

Hope this is helpful. Cheers!!

6 Likes