7 ms·
I hate you and and the awful layout you have just introduced me to... Also, that is how I will be formatting all my SQL from now on.
by kcolford 5y ago
I hate you and and the awful layout you have just introduced me to... Also, that is how I will be formatting all my SQL from now on.
- fnord123 5y agoalt styling SELECT a, b, COUNT(*) as count FROM table WHERE cond1 AND cond2 GROUP BY a, b ORDER BY count DESC
- EamonnMR 5y agoThat's the one I'm familiar with. The capitalized keywords help give you that Relational Database feel.
- munk-a 5y agoCapitalized keywords and section declarations on their own lines helps with quick comprehension for me at least
- snidane 5y agoI've seen this one in the wild and have objections to it. - why capitalize KEYWORDS. We're no longer in 1970s. We use colors - why waste so much space. Why not just put table on the same line with from. With joins this just bloats up - for complicated conditions they have to be put on their own lines. Do I give each AND a separate line and waste ever more space?
- bntyhntr 5y agoMy editors and code review tools do not format or highlight sql for me when it's embedded in other files - eg java. I find capitalized keywords to be very convenient. Of course at that point, I can't run sqfluff on it either but this thread has already devolved fairly quickly.
- wodenokoto 5y ago- Half my SQL queries are written inside some other script, like Python or bash, so capitalization is nice. - Space is not wasted when it it makes code more readable. - Yes, and also give the columns in select their own lines. So nice to read. Space well spend!
- snidane 5y agoGood points. Maybe there is a difference between a SQL script embedded occasionally somewhere in python, for which this style probably makes sense. For heavy SQL codebases found in data analytics, there are better styles.
- fiddlerwoaroof 5y agoI’ve always formatted my SQL like this, but I don’t remember learning it from anyone else or seeing anyone else do it.