SQL style guide?
I'd like to start enforcing SQL style for our charts to make it easier for our analysts to jump between each other's reports.
Does anyone have SQL style guide they recommend? We actually use similar to what Periscope uses in their blog posts -- all lower case, 2 space indent, each select and where condition on their own line, etc -- so I'm hoping to find one that uses that same style.
I will look into this tomorrow, but are you familiar with cmd/ctrl-shift-L to automatically format your code in Periscope Data? If not, prepare to be amazed. :)
Internally, we generally use that as our "style guide", with the exception that sometimes we condense case statements a bit.Reply
I quite like the Periscope Formatter, with exceptions to some treatments of functions and parentheses, it's good enough that we don't need to enforce tabs/spaces or the syntactical boring stuff.
That said, for the more abstract part of style, I like to point analysts towards this blog on naming in programming.
I think it captures the hard part of style, like what things go in what chunks, and what to call those chunks. So temporary table / CTE names, column names, calculated field names, and the order in which you spin those up.
There isn't a great way to write all that stuff down aside from the abstract process he lays out, which we mostly enforce through making sure new analysts are learn SQL from only a few sources internally, and constantly reviewing each other's code to make those tweaks.Reply
Mark Lampert We really like this style guide (in addition to the Periscope formatter) :
There's also a style guide from Kickstarter with great examples of dos and don'ts: https://gist.github.com/fredbenenson/7bb92718e19138c20591Reply